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

svelte-check does not respect excludes when specifying a tsconfig file #1048

Closed
9ParsonsB opened this issue Jun 11, 2021 · 1 comment
Closed
Labels
question A user question upstream

Comments

@9ParsonsB
Copy link

  • you have searched and found no existing open issue with the problem at hand

Describe the bug
svelte-check reports errors in node_modules when referencing a tsconfig - even for files that are not referenced and/or in the exclude in the tsconfig.json

To Reproduce
repo

  • create svelte repo with typescript support
  • reference a library with questionable import paths (e.g. "svelte-loading-spinners": "0.1.5")
  • yarn install
  • run svelte-check --tsconfig tsconfig.json

Expected behavior
Files in node_modules are excluded unless explicitly referenced or included (?)

System (please complete the following information):

  • OS: Windows
  • IDE: VSCode
  • Plugin/Package: svelte-check

Additional context

  • This issue was not present in 1.5.2
  • My tsconfig has not changed, only the svelte-check package
@9ParsonsB 9ParsonsB added the bug Something isn't working label Jun 11, 2021
@dummdidumm
Copy link
Member

To me this is a bug within the svelte-loading-spinners library. It copies the unpreprocessed files written in TypeScript into dist/ts and tells TypeScript to look there for the type definitions. But within that there are no type definitions but real Svelte files, and they have import paths which are wrong because the build script apparently contains a little bug there not rewriting the import paths or something.

The tsconfig exclude does not mean that things inside node_modules are not completely excluded from the check. If a file that matches the include pattern (App.svelte) references something that matches the exclude pattern (svelte-loading-spinners), it's still included into the list of files and therefore checked.
One can tell TypeScript through skipLibCheck to skip checking of d.ts files, which is mostly used to skip diagnostics on node_modules, because TypeScript will mostly see those within node_modules. But in this case real Svelte files are referenced and that skip flag does not apply. One could argue the flag should be interpreted as "also skip Svelte files inside node_modules" in the context of svelte-check but I'm not very convinced that this is a good idea yet, especially since TypeScript will also throw errors on .ts files that are wrong and inside node_modules.

So to summarize, the library in question needs to change its build output and provide real d.ts type definitions of Svelte files instead of using a hacky workaround. For now this most likely means writing these by hand, but we are working on automating this in the context of SvelteKit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A user question upstream
Projects
None yet
Development

No branches or pull requests

2 participants