-
-
Notifications
You must be signed in to change notification settings - Fork 205
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 fails if importing TS in monorepo #2132
Comments
I tried debugging this just then and I think the issue stems from here: https://github.com/sveltejs/language-tools/blob/master/packages/language-server/src/svelte-check.ts#L229 The Typescript compiler program when initially parsing the program processes the However when svelte-check gets the list of files in the program Typescript returns the non-symlinked path to |
The problem is that our |
Yeah. They should only contain root files. That's the project files in our code base plus client-opened files. If the opened files are not there, TypeScript throws an error for missing source files when requesting language features for those files. |
What I dug up is that the language service's And when it does that in the context of So it sounds like we should filter the list of script file names before returning it - something like "is this not inside node_modules or opened in the client". Does that make sense, or will this result in breakage for the IDE case? |
I think we can only return project files and client files. Maybe instead of tracking client files in the document manager, we track it in a property of Document so it can be carried over to the script snapshot. But that causes some tests to fail because we're relying on |
Could you open a draft PR with what you tried which isn't working, just so I can take a closer look at what exactly you tried? |
#2132 This PR moved the tracking of "document is open by the client" to document so it can be copied over to ts snapshot and create a new documentManager.openClientDocument to replace openDoucment in existing places. This will mark the file as client files in one method call, so we don't have to add markAsOpenByClient to all existing tests. The reason that we need client files is that files might be opened by the client and not in the project files. One reason is that the user has an empty include in the tsconfig or has the default one. Also, we didn't watch Svelte files with File Watcher. So the new svelte file won't be in the project files. We probably should do it for something like git checkout, but that can be a separate PR. We have to use a TypeScript internal API and add a layer of synchronization because of a module resolution bug. The way getSnapshot prevents the problem before the amount of root files have changed so that TypeScript will check more thoroughly. The existing test is different from how it'll work in typical cases. It probably worked when it was introduced, but we later changed to not run getSnapshot in new ts/js files, so it's not actually preventing the error.
Describe the bug
In a monorepo setup importing a Typescript file from outside a package's tsconfig.json
rootDir
file Typescript will complain with the following when runningsvelte-check
:This happens even doing an absolute import of a monorepo dependency (eg.
import "dep"
) which is symlinked into node_modules. Runningtsc
does not complain in this case, only when runningsvelte-check
does it complain.Reproduction
Clone and run commands from readme: https://github.com/jakzo/svelte-ts-monorepo-issue
Expected behaviour
svelte-check shows the same Typescript errors as tsc and allows importing from symlinked dependencies in node_modules.
System Info
Which package is the issue about?
svelte-check
Additional Information, eg. Screenshots
No response
The text was updated successfully, but these errors were encountered: