Skip to content

Project References support #2148

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

Closed
ziggi opened this issue Sep 3, 2023 · 1 comment
Closed

Project References support #2148

ziggi opened this issue Sep 3, 2023 · 1 comment
Labels
feature request New feature or request

Comments

@ziggi
Copy link

ziggi commented Sep 3, 2023

Describe the bug

I'm using TypeScript's Project References and it's looks like Svelte extension didn't work with it.

Extension output:

Initialize language server at  file:///d%3A/dev/svelte-ts-projects
Initialize new ts service at  d:/dev/svelte-ts-projects/tsconfig.json
Trying to load configs for d:/dev/svelte-ts-projects
Loaded config at  d:\dev\svelte-ts-projects\proj1\svelte.config.js
SnapshotManager File Statistics:
Project files: 0
Svelte files: 1
From node_modules: 0
Total: 1

Reproduction

Clone https://github.com/ziggi/svelte-ts-projects
Open it in VS Code and open svelte-ts-projects\proj1\svelte\TestComponent.svelte file.
You will see Cannot find module '@shared/SharedTest' or its corresponding type declarations.

Expected behaviour

It should just work.

System Info

Svelte for VS Code v107.10.0

Version: 1.78.2 (user setup)
Commit: b3e4e68a0bc097f0ae7907b217c1119af9e03435
Date: 2023-05-10T14:39:26.248Z
Electron: 22.5.2
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.22621
Sandboxed: No

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

image
@ziggi ziggi added the bug Something isn't working label Sep 3, 2023
@jasonlyu123 jasonlyu123 added feature request New feature or request and removed bug Something isn't working labels Sep 8, 2023
@jasonlyu123 jasonlyu123 changed the title VS Code shows error on paths imports with TypeScript's Project References Project References support Jan 19, 2024
@jasonlyu123
Copy link
Member

Some updates. I am making this the mega thread for project reference support since we didn't support it at all. Leaving some notes here as an update on the progress and also as a reminder in case I forgot about it, which I often do 😅.

The problem with this one is that project reference is used to load different tsconfig that doesn't use the name "tsconfig.json". Vite templates also often use this to differentiate server files and web files. So module resolution needs to use the redirected tsconfig.

#2262 has another problem with the "Build-Free Editing with Project References". Repro: https://github.com/mamidenn/module-resolution-repro. The problem with this one is the packages.json exports point to non-existent .dts files. And with the project reference, it should be redirected to the corresponding source file in the source project. typescript uses internal API to expose a "compilerHost", from the language service program to the module loader. There is handling in it to redirect the dist .dts to the source file.

For general project reference. There is also a problem with the caching of the parsed tsconfig. We need to implement the getParsedCommandLine method otherwise TypeScript will try to read the extended tsconfig from disk in every keystroke. But not the one in project references, that one is cached. While checking this I also found a regression with the @\types packages.json. The previous cache was removed when we added an auto-import cache because I thought there was a cache for it but the cache doesn't apply to @ types. We also probably need to add file watching to the project reference config file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants