quasarframework / quasar

Quasar Framework - Build high-performance VueJS user interfaces in record time

Home Page:https://quasar.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Since updating to Quasar 2.16.0 functions returning the `any` type.

rstoenescu opened this issue · comments

Discussed in #17170

Originally posted by MartinX3 May 6, 2024
I updated to Quasar 2.16.0 and @quasar/app-vite 2.0.0-beta.12.
Now eslint errors out because as example this variable has now the type any.

import { date, } from 'quasar'
const daysInMonth = date.daysInMonth(new Date())

I look at the code in my IDE and also hover over the function.
It says the return type is number.
But eslint says any.
Adding the variable type via my IDE also puts the any at it.

And updating app-vite to beta 12 errors out with

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/home/runner/work/[...]/node_modules/quasar/wrappers' is not supported resolving ES modules imported from /home/runner/work/[...]/quasar.config.ts.temporary.compiled.1715059034987.mjs
Did you mean to import "quasar/wrappers/index.js"?
```</div>

Fixed in Quasar v2.16.1

@MartinX3 and @UkonnRa pls try with v2.16.1
Also, make sure that you restart your IDE to eliminate any sync issues.

Impressive! Everything works as expected in 2.16.1! Thanks for your quick support!!!

@rstoenescu
Thank you.
quasar dev is fixed but quasar build is (now) broken.

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/runner/work/[...]/[...]/node_modules/.pnpm/@quasar+vite-plugin@1.6.0_@vitejs+plugin-vue@5.0.4_vite@5.2.10_@types+node@20.12.10_sass@1.75_fxwfyg26cdo6pyzenxcq254jcq/node_modules/quasar/dist/transforms/import-transformation.js' imported from /home/runner/work/[...]/[...]/node_modules/.pnpm/@quasar+vite-plugin@1.6.0_@vitejs+plugin-vue@5.0.4_vite@5.2.10_@types+node@20.12.10_sass@1.75_fxwfyg26cdo6pyzenxcq254jcq/node_modules/@quasar/vite-plugin/src/vue-transform.js
    at finalizeResolution (node:internal/modules/esm/resolve:265:11)
    at moduleResolve (node:internal/modules/esm/resolve:933:10)
    at defaultResolve (node:internal/modules/esm/resolve:1157:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:2[34](https://github.com/[...]]/[...]/actions/runs/8982482311/job/24670183936#step:7:35):38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
    at link (node:internal/modules/esm/module_job:86:[36](https://github.com/[...]/[...]/actions/runs/[...]/job/[...]#step:7:37)) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///home/runner/work/[...]/[...]/node_modules/.pnpm/@quasar+vite-plugin@1.6.0_@vitejs+plugin-vue@5.0.4_vite@5.2.10_@types+node@20.12.10_sass@1.75_fxwfyg26cdo6pyzenxcq254jcq/node_modules/quasar/dist/transforms/import-transformation.js'
}

Reinstall from scratch pls. Seems like it's already got the old version of q/vite-plugin and not checking for the newer one.

I already removed the node_modules and my pnpm-lock-yaml.
And also my github CI has this problem, too, which doesn't cache the node_modules.
I use 2.16.1 and app-vite beta 12.

I can confirm that the issue is resolved by testing it with both the dev and build commands

This is weird.
I removed the node_modules and pnpm-lock-yaml a second time in this 5 minutes and now @quasar/app-vite@2.0.0-beta.12 added the '@quasar/vite-plugin': 1.7.0 dependency.
Black magic or so.
It works now.

I'll enforce q/app-vite beta to install the newer q/vite-plugin (though it should by default). But working on improving some other stuff before making a new release.

Thanks everyone for your feedback!

@rstoenescu
Thank you.
By the way speaking about modules.
Why is quasar using moduleResolution: node with module: esnext in the tsconfig?
According to https://www.typescriptlang.org/tsconfig/#moduleResolution the node value is a deprecated value which got renamed to node10.
The newer ones are node16 / nodenext and the compatibility value bundler.
(module also got the newer value node16 / nodenext)

Node 10 is EOL since 2021-04-01 and Node 16 since 2023-09-11.

Since quasar 2.16 got its package internal build system to ESM it might be useful to refactor the tsconfig-preset in app-vite.

@yusufkandemir pls check the above comment from Martin

Thank you.
I remember now I did mark him in march, too.
#9455 (comment)

@rstoenescu
v2.16.1 still have a problem: not able to import useQuasar and QuasarPluginOptions

image

@panmenghan can u show me the output of quasar info pls?

And a reproduction repo would be nice

@rstoenescu
https://github.com/panmenghan/quasar-bug

Install with pnpm i

Open index.ts with vscode, and the error will show

@panmenghan
Seems an issue with your tsconfig.json. Changing the following works:

"module": "esnext",
"moduleResolution": "node",

Better to use

"moduleResolution": "Bundler",
"verbatimModuleSyntax": true

node alias node10 is really outdated.
The modern moduleResolution are node16 nodenext bundler

In my case I also use the modern "type": "module", in my package.json and

"module": "esnext",
"moduleResolution": "node",

leads to as example Cannot find module '@yeger/vue-masonry-wall' or its corresponding type declarations. with the vue-tsc checker.
bundle as above fixed it for me.

@MartinX3 @rstoenescu
Thanks.

Change the value of moduleResolution to Bundler or node both works.

But if quasar support all the moduleResolution mode would be better.

The node16 mode require all the relative import(dist/types/*.d.ts) explicitly add .js extension and imported folder with /index.js suffix. But if the Bundler or node mode, the .js or ./index.js can be omited.

We'll improve this in the near future. Right now I just wanted to give a hint on where the problem is coming from. Did not mean that module + moduleResolution should only have that values.