Closed richardsimko closed 1 year ago
Adding noEmit
option disables importing SFC files, so I think adding the option is not the solution.
src/main.ts:10:17 - error TS2307: Cannot find module './App.vue' or its corresponding type declarations.
10 import App from './App.vue'
~~~~~~~~~~~
Oops, I've only tested in command line with the --noEmit
flag, so I didn't notice this issue. Thanks for reporting!
Adding
noEmit
option disables importing SFC files, so I think adding the option is not the solution.
I can't reproduce it locally. Could you open a new issue with a reproducible repository?
I did find a caveat of noEmit
though: https://github.com/microsoft/TypeScript/issues/49844
If the root tsconfig.json
is like this: https://github.com/vuejs/create-vue-templates/blob/fb8f80202ebcc33258742f602e6dd9399b417ead/typescript/tsconfig.json and the tsconfig.node.json
is changed to extend from @vue/tsconfig/tsconfig.json
, which includes noEmit
, TypeScript would throw.
I have ideas to mitigate this issue, but they are too complicated and might not be worth the effort.
🤔 Maybe the allowImportingTsExtensions
flag isn't that needed by default and I should revert it back…
To mitigate this issue, I can:
@vue/tsconfig
in tsconfig.node.json
;allowImportingTsExtensions
in it.create-vue
tsconfig templates to always use files: []
in the root tsconfig
ts-node
because it doesn't support solution-style tsconfigs; options have to be set in the root one. But we'll see.emitDeclarationOnly
, which could be recommended for Node + Vue usage. This can also be used to make Vitest type-checking faster and more comprehensible.On the other hand, If I drop allowImportingTsExtensions
by default in this package, I still plan to do 2 & 3, but the documentation in this repository could be much simpler. Users don't typically go here for documentation anyway.
After some thought and reading this issue, I think allowImportingTsExtensions
only serves a very niche use case (at this moment):
.js
to .ts
, which, I believe would be very rare. Such a shared codebase isn't likely to need a Vue-specific configuration, either.So, I plan to drop allowImportingTsExtensions
in the default configuration.
I might add a section in the documentation on it later, if there are use cases beyond aesthetics.
The current config gives the following schema error:
Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set
.Setting
"noEmit": true,
incompilerOptions
seems to resolve it, as Vite is doing the actual transpiling this seems to work fine.