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

warn svelte input only when program has no svelte files at all #2488

Merged
merged 5 commits into from
Sep 18, 2024

Conversation

jasonlyu123
Copy link
Member

@jasonlyu123 jasonlyu123 commented Sep 6, 2024

While implementing the delayed check. I found out that tsserver actually assigns files that aren't project files into the service that loads the files through import. And this has all sorts of inconsistent states 😅. So still need to compare the behavior to tsserver.

Fixes #2486
Fixes #2485

@dummdidumm
Copy link
Member

dummdidumm commented Sep 6, 2024

Honestly, if this makes for too much complicated logic, and if this doesn't uncover an unrelated inconsistencies bug (judging from the changed code it looks you found some other things), then I would just not show the error in VS Code, and only show it in svelte-check, by checking if there are any Svelte file in the program files we iterate over to get all diagnostics.

@jasonlyu123
Copy link
Member Author

The reason for the project-assign change is that: If we only error when the program doesn't have any svelte files there might be an inconsistency between the editor and the svelte-check. The svelte file would use our default config, but it would use the tsconfig in svelte-check. For example, if the tsconfig.json has strict: true the diagnostic will be very different. So I feel like if we were to change this we should, at least in most cases, align with the tsserver behaviour.

@dummdidumm
Copy link
Member

The svelte file would use our default config, but it would use the tsconfig in svelte-check

When would that happen? I'm not sure I follow. Can you give an example?

@jasonlyu123
Copy link
Member Author

You can create a create-vite project with typescript and svelte. Then update svelte-check to v4 and remove Svelte files from the include config.

In the editor, the current logic is to assign files to a shared service without a tsconfig. But svelte-check is the other way around it loads the tsconfig and loops through the files in the program.

@dummdidumm
Copy link
Member

dummdidumm commented Sep 6, 2024

But isn't that correct? In the editor you can access files outside of the includes of your tsconfig definition, so they need to go somewhere. For svelte-check (and IIUC also tsc) that's not the case, because those only look at the included files, and then traverse from there. Anything that is not found through that traversal just doesn't exist for them.

@jasonlyu123
Copy link
Member Author

The change is only for files that are already in the program. They would already be checked in svelte-check. The other files are still assigned to the implicit project, i.e. as if there isn't a tsconfig.

@jasonlyu123 jasonlyu123 marked this pull request as ready for review September 16, 2024 06:47
Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I realized that this fixes exactly what I was worrying about

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants