Open webJose opened 1 month ago
exclude
doesn't prevent files from being checked it only prevents them from being loaded as entry files. All files loaded either as entry files or because of an import will be checked. This is the behaviour of tsc as well so we are unlikely to change this. There is a proposal in the TypeScript repo to add a flag only to disable .d.ts
check in node_modules but it was a couple of years ago and doesn't seem to be on track to be implemented.
Can you share what kind of .d.ts
file you want to check? If it's just some types you can just use the ts file instead and it'll be checked. That also work if you plan on using JSDoc in case that is why you use .d.ts
instead of a regular ts file.
I need to create ambient modules:
declare module "@scope/utility-module" {
...
}
These are modules exported by micro-frontends that are then consumed by other micro-frontends. All these are externalized, and then defined in an import map.
That should work in a ts file as well. But if the module has an import map why do you have to declare it manually? Is there any error that can't be fixed in the @scope/utility-module
module? Or maybe your module resolution isn't bundler or nodenext?
The d.ts file is for Intellisense support. If not included, VS Code will report "could not find module definition or its declaration", or something like that.
Oh right, it's import map, not export map. You do need the "declare module" or define it in the "paths" config. But yeah you can also use "define module" in a ts file so you don't disable skipLibCheck.
Ok, thanks. So long story short: The exclude
property in tsconfig.json
is only for a subset of the TypeScript functionality and it doesn't cover type checking. Svelte tooling has no saying about this (currently or in the future?) and we are at the mercy of Microsoft.
Accurate?
It is a common misunderstanding. It's just not what the config is meant for. https://www.typescriptlang.org/tsconfig/#exclude
Describe the bug
Maybe this is not a bug, and maybe it is just me unable to configure things properly. Since I have struggled with this for a couple of hours already, I'll venture myself and post it as a bug. If you know better, please, by all means correct me.
I want to set
skipLibCheck: false
in mytsconfig.json
file because I am declaring some modules in .d.ts files and I want them checked. Doing this certainly makes VS Code correct my mistakes. Good. However,svelte-check
, when run, checks the d.ts files insidenode_modules
. I have tried many variations for excluding thenode_modules
folder without success.skipLibCheck: false
,exclude: [ "node_modules" ]
skipLibCheck: false
,exclude: [ "node_modules/" ]
skipLibCheck: false
,exclude: [ "./node_modules" ]
skipLibCheck: false
,exclude: [ "./node_modules/" ]
skipLibCheck: false
,exclude: [ "./node_modules/*" ]
skipLibCheck: false
,exclude: [ "./node_modules/**" ]
skipLibCheck: false
,exclude: [ "node_modules/**" ]
skipLibCheck: false
,exclude: [ "node_modules/**/*.d.ts" ]
And the list goes on and on.
Reproduction
npm create vite@latest
. Select Svelte, then Typescript.npm install svelte@next svelte-check@4
tsconfig.json
withskipLibCheck: false
and your favorite version ofexclude
.Let me know how it goes. For me, it complains about
node_modules/svelte/types/index.d.ts
andnode_modules/svelte-check/dist/src/svelte-shims-v4.d.ts
.Expected behaviour
No definition files are checked inside the
node_modules
folder.System Info
Which package is the issue about?
svelte-check
Additional Information, eg. Screenshots
No response