-
-
Notifications
You must be signed in to change notification settings - Fork 421
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
Volar doesn't perform the source file redirect for project references #1815
Comments
Added a MWE. |
It might be that Volar just doesn't work with project references properly at all... Weird stuff... |
It seems to be a troublesome problem, sorry I can't check quickly... |
This is quite a complex config, I'm trying to create a monorepo project with multiple Vite apps and libs with the best DX I can get. But as always, it is proving a bit difficult. See vitejs/vite#9979 |
I think this is related to #1344 |
The problem is that Volar seems to be ignoring Declaration Maps (.d.ts.map files) so it doesn't redirect to the source when using Go To Definition. The built-in typescript extension redirects correctly using the .d.ts.map file. |
Actually, the built-in typescript extension doesn't even need the .d.ts.map files to redirect correctly. It just sees that project references are enabled and automatically decides to redirect to the source when the developer uses Go To Definition. Volar, on the other hand, displays "Cannot find module 'XXX' or its corresponding type declarations." when project references are enabled and it can't find the declaration files. If it can find the declaration files with project references enabled it then goes to the declaration file instead of the source file when the developer uses Go To Definition. |
That's the source file redirect thing introduced in TS Server 3.7 that I linked in the PR description. |
|
@johnsoncodehk Thia will require generating declaration maps (On disk .d.ts.map files) and keeping them up-to-date, which are not generated by TS by default, nor by Vite, and require running |
|
Yes. But instead of supporting and using project references it falls back to non-project references mode, which means for go to definition to work I will have to generate declaration maps, something I don't need if project references are used and working correctly. It will be much more convenient for Volar to properly support project references rather than ignore them. |
You only need define
|
|
Where are you see the error? (I can't find it) |
[{
"resource": "/Users/segevfiner/junk/vite-issue-1815/apps/web/src/App.vue",
"owner": "_generated_diagnostic_collection_name_#0",
"code": "6305",
"severity": 8,
"message": "Output file '/Users/segevfiner/junk/vite-issue-1815/packages/foo-lib/src/index.d.ts' has not been built from source file '/Users/segevfiner/junk/vite-issue-1815/packages/foo-lib/src/index.ts'.",
"source": "ts",
"startLineNumber": 4,
"startColumn": 28,
"endLineNumber": 4,
"endColumn": 37
}] And, of course, as described, this doesn't happen in |
I think this is not project references problem, the problem is vue language server and tsserver pickup different tsconfig for vue language server: apps/web/tsconfig.app.json But this is expected behavior not a bug, because TypeScript have change this behavior before, but they don't have specification for tsconfig pickup priority. Reopen this for later inspection. |
@johnsoncodehk That one is an issue, which I reported separately in vuejs/create-vue#159, trying to add a project reference to both vitest and app configs doesn't seem to solve this issue. |
You can config |
Cool. I'll try once it's released and let you know if this fixed this issue. |
It seems to be working now with the new setting after setting |
Argh. Spoke too soon. I had a stray Steps to reproduce
|
@johnsoncodehk Please reopen if you can reproduce the issue. It might be something wrong in tsserver with the way we set up the tsconfig in |
- issue: [Volar doesn't perform the source file redirect for project references · Issue #1815 · vuejs/language-tools](vuejs/language-tools#1815) - reproduce: [HenryC-3/D2N at fix-ts(6305)](https://github.com/HenryC-3/D2N/tree/fix-ts(6305))
- issue: [Volar doesn't perform the source file redirect for project references · Issue #1815 · vuejs/language-tools](vuejs/language-tools#1815) - reproduce: [HenryC-3/D2N at fix-ts(6305)](https://github.com/HenryC-3/D2N/tree/fix-ts(6305))
should be resolved with: volarjs/volar.js#24 |
When's importing a file from a project reference, Volar doesn't redirect to the source file for completion, type checking, like the builtin tsserver support does: https://www.typescriptlang.org/tsconfig#disableSourceOfProjectReferenceRedirect. This allows type checking & auto completion, etc. To work in VS Code even before you build the dependent project's
.d.ts
.Steps to reproduce
pnpm i
apps/web/src/App.vue
, check the offending import line which will warn withapps/web/src/main.ts
, notice there is no error for the same import there.P.S. Why do I need https://github.com/segevfiner/vite-issue-1815/blob/229ca43e34e86b4d7bbb14940f7e5b00ca90dc42/apps/web/tsconfig.app.json#L10-L11 shouldn't this be figured out from the dependency between the projects? Is this TypeScript possibly getting confused due to the
tsconfig.json
not really specifying the actual output paths and them not matching with what Vite outputs?The text was updated successfully, but these errors were encountered: