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 ignoring jsconfig.json's exclude option #1234

Closed
kierangilliam opened this issue Nov 8, 2021 · 2 comments
Closed

svelte-check ignoring jsconfig.json's exclude option #1234

kierangilliam opened this issue Nov 8, 2021 · 2 comments
Labels
breaking change bug Something isn't working

Comments

@kierangilliam
Copy link

svelte-check will not use a jsconfig.json's exclude option to ignore .svelte files.

Please see this to reproduce.

If you open this project in vscode and navigate to jsconfig.json you'll see that src/routes is excluded from type checking. This is confirmed to work for *.js files (see src/routes/in-route.js). However, as seen in src/routes/index.svelte, the language server will ignore the exclusion of this folder and perform type checking.

@kierangilliam kierangilliam added the bug Something isn't working label Nov 8, 2021
@jasonlyu123
Copy link
Member

Typescript's tsserver has a concept called inferred project. It seems like if according to the include and exclude the file doesn't belong to any config file, It would fall into this inferred project category. So it's not typescript respect the config and doesn't type check the in-route.js file. It's that the jsconfig.json doesn't apply to that file. If you enable the strict mode in the jsconfig.json and has a variable with string | undefined type in both in-route.js and in-lib.js.

/**@type {string | undefined}*/
let a;

Hover over it in the editor and you'll see that in-route.js shows let a: string while in-lib.js shows let a: string | undefined.

So technically the difference is that we have a different approach to determine whether the file belongs to the jsconfig/tsconfig.

But I don't know if we can make it consistent with the tsserver. Historically, setting svelte files in the include config doesn't do anything. When analysing the config file, typescript won't tell us if the file belongs to the config file. So we only check if the file is in the directory where the config is. Although including the svelte file in the include does include the file now. But there should be a lot of people who don't have svelte files in the include. This means if we change this behaviour it'll be a breaking change.

And by the way, your exclude actually doesn't do anything. As the route path is not in the include. You can see the explanation in the typescript doc

@kierangilliam
Copy link
Author

Thanks for your explanation. So, the best workaround to this issue would be to do the following in .vscode/settings.json, yeah?

{
	"svelte.plugin.typescript.diagnostics.enable": false
}

But there should be a lot of people who don't have svelte files in the include. This means if we change this behaviour it'll be a breaking change.

Yeah I agree that wouldn't be ideal. Instead of requiring people to use include, is it possible to grab the project's tsconfig/jsconfig's exclude and ensure those files are also ignored?

And by the way, your exclude actually doesn't do anything. As the route path is not in the include. You can see the explanation in the typescript doc

Also thanks for this; I didn't realize! The example is updated to correct for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants