Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quasar.config file configure callback should support async #17268

Closed
glorat opened this issue Jun 9, 2024 · 4 comments · Fixed by #17291
Closed

quasar.config file configure callback should support async #17268

glorat opened this issue Jun 9, 2024 · 4 comments · Fixed by #17291
Labels
area/typescript bug/2-confirmed We have reproduce the problem and confirmed that this is a bug. flavour/quasar-cli-vite flavour/quasar-cli-webpack good first issue Easy issue which doesn't require previous codebase knowledge kind/bug 🐞 Qv2 🔝 Quasar v2 issues

Comments

@glorat
Copy link
Contributor

glorat commented Jun 9, 2024

What happened?

Using the latest appvite2 whre quasar.config.ts can now be specified in typescript. Per the docs (https://quasar.dev/quasar-cli-vite/quasar-config-file#the-basics) and reality, configure can be made an async function. However the typescript definitions define

declare module "quasar/wrappers" {
...

  function configure(callback: ConfigureCallback): ConfigureCallback;

As a result, vue-tsc will fail if an async callback is defined

What did you expect to happen?

Compilation should work... the type definition should be updated to something like
declare module "quasar/wrappers" {

  function configure(callback: ConfigureCallback): ConfigureCallback | Promise<ConfigureCallback>;

Reproduction URL

https://stackblitz.com/edit/stackblitz-starters-tymaet?file=quasar-project%2Fquasar.config.ts

How to reproduce?

npm init quasar

✔ What would you like to build? › App with Quasar CLI, let's go!
✔ Project folder: … appvite2
✔ Pick Quasar version: › Quasar v2 (Vue 3 | latest and greatest)
✔ Pick script type: › Typescript
✔ Pick Quasar App CLI variant: › Quasar App CLI with Vite 5 (BETA | next major version - v2)
✔ Package name: … appvite2
✔ Project product name: (must start with letter if building mobile apps) … Quasar App
✔ Project description: … A Quasar Project
✔ Author: … Kevin Tam <[email protected]>
✔ Pick a Vue component style: › Composition API with <script setup>
✔ Pick your CSS preprocessor: › Sass with SCSS syntax
✔ Check the features needed for your project: › Linting (vite-plugin-checker + ESLint + vue-tsc), State Management (Pinia), axios, vue-i18n
✔ Pick an ESLint preset: › Prettier

(The key selection was Typescript + Vite 5)

Modify quasar.config.ts to add async as follows
export default configure(async(ctx) => {

quasar build

now fails

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

TypeScript Support

Platforms/Browsers

Other

Quasar info output

Operating System - Darwin(23.5.0) - darwin/arm64
NodeJs - 20.11.1

Global packages
  NPM - 10.2.4
  yarn - 1.22.19
  pnpm - Not installed
  bun - Not installed
  @quasar/cli - 2.4.1
  @quasar/icongenie - 2.5.4
  cordova - Not installed

Important local packages
  quasar - 2.16.4 -- Build high-performance VueJS user interfaces (SPA, PWA, SSR, Mobile and Desktop) in record time
  @quasar/app-vite - 2.0.0-beta.14 -- Quasar Framework App CLI with Vite
  @quasar/extras - 1.16.11 -- Quasar Framework fonts, icons and animations
  eslint-plugin-quasar - Not installed
  vue - 3.4.27 -- The progressive JavaScript framework for building modern web UI.
  vue-router - 4.3.2
  pinia - 2.1.7 -- Intuitive, type safe and flexible Store for Vue
  vuex - Not installed
  vite - 5.2.13 -- Native-ESM powered web dev build tool
  vite-plugin-checker - Not installed
  eslint - 8.57.0 -- An AST-based pattern checker for JavaScript.
  esbuild - 0.20.2 -- An extremely fast JavaScript and CSS bundler and minifier.
  typescript - 5.3.3 -- TypeScript is a language for application scale JavaScript development
  workbox-build - Not installed
  register-service-worker - Not installed
  electron - Not installed
  electron-packager - Not installed
  @electron/packager - Not installed
  electron-builder - Not installed
  @capacitor/core - Not installed
  @capacitor/cli - Not installed
  @capacitor/android - Not installed
  @capacitor/ios - Not installed

Relevant log output

App •  WAIT  • Compiling of SPA UI with Vite in progress...
quasar.config.ts:10:26 - error TS2345: Argument of type '(ctx: QuasarContext) => Promise<{ boot: string[]; css: string[]; extras: string[]; build: { target: { browser: string[]; node: string; }; vueRouterMode: string; vitePlugins: ((string | { ssr: boolean; include: string[]; })[] | (string | ... 1 more ... | { ...; })[])[]; }; ... 8 more ...; bex: { ...; }; }>' is not assignable to parameter of type 'ConfigureCallback'.
  Type 'Promise<{ boot: string[]; css: string[]; extras: string[]; build: { target: { browser: string[]; node: string; }; vueRouterMode: string; vitePlugins: ((string | { ssr: boolean; include: string[]; })[] | (string | { vueTsc: { ...; }; eslint: { ...; }; server?: undefined; } | { ...; })[])[]; }; ... 8 more ...; bex: { ...' has no properties in common with type 'QuasarConf'.

10 export default configure(async(ctx) => {
                            ~~~~~~~~~~~~~~~

Additional context

The use of quasar.config.ts is brand new as part of app-vite2. Call this a beta test bug report!

@glorat glorat added kind/bug 🐞 Qv2 🔝 Quasar v2 issues labels Jun 9, 2024
Copy link

github-actions bot commented Jun 9, 2024

Hi @glorat! 👋

It looks like you provided an invalid or unsupported reproduction URL.
Do not use any service other than Codepen, jsFiddle, StackBlitz, Codesandbox, and GitHub.
Make sure the URL you provided is correct and reachable. You can test it by visiting it in a private tab, another device, etc.
Please edit your original post above and provide a valid reproduction URL as explained.

Without a proper reproduction, your issue will have to get closed.

Thank you for your collaboration. 👏

@glorat
Copy link
Contributor Author

glorat commented Jun 9, 2024

Hi @glorat! 👋

It looks like you provided an invalid or unsupported reproduction URL. Do not use any service other than Codepen, jsFiddle, StackBlitz, Codesandbox, and GitHub. Make sure the URL you provided is correct and reachable. You can test it by visiting it in a private tab, another device, etc. Please edit your original post above and provide a valid reproduction URL as explained.

Without a proper reproduction, your issue will have to get closed.

Thank you for your collaboration. 👏

Per requested, I've added a StackBlitz

@yusufkandemir yusufkandemir added flavour/quasar-cli-webpack bug/2-confirmed We have reproduce the problem and confirmed that this is a bug. good first issue Easy issue which doesn't require previous codebase knowledge and removed bug/0-needs-info Need more info to reproduce labels Jun 10, 2024
@yusufkandemir
Copy link
Member

Related lines:

type ConfigureCallback = (context: QuasarContext) => QuasarConf;

type ConfigureCallback = (context: QuasarContext) => QuasarConf;

@yusufkandemir yusufkandemir changed the title quasar.config.ts configure return type should support async quasar.config file configure callback should support async Jun 10, 2024
@glorat
Copy link
Contributor Author

glorat commented Jun 17, 2024

type ConfigureCallback = (context: QuasarContext) => QuasarConf | Promise<QuasarConf>;

would probably do the trick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/typescript bug/2-confirmed We have reproduce the problem and confirmed that this is a bug. flavour/quasar-cli-vite flavour/quasar-cli-webpack good first issue Easy issue which doesn't require previous codebase knowledge kind/bug 🐞 Qv2 🔝 Quasar v2 issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants