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

[Vue TS Plugin] The tsconfig selected for root file and external file is inconsistent #57632

Closed
1 task done
johnsoncodehk opened this issue Mar 4, 2024 · 3 comments
Closed
1 task done
Assignees
Labels
External Relates to another program, environment, or user action which we cannot control.

Comments

@johnsoncodehk
Copy link

johnsoncodehk commented Mar 4, 2024

Acknowledgement

  • I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.

Comment

Issues: vuejs/language-tools#3951, vuejs/language-tools#1815

For the root file, tsserver selects the last matching tsconfig in the list of tsconfig references for it.
But for external files, tsserver selects the first matching tsconfig in the list of tsconfig references for it.

Steps to reproduce

  1. Clone segevfiner/vite-issue-1815
  2. Open the repo in VSCode, install marketplace.visualstudio.com/items?itemName=Vue.volar 2.0.4
  3. Open apps/web/src/main.ts, and check the tsconfig at status bar, it's apps/web/tsconfig.app.json
    image
  4. Open apps/web/src/App.vue, and check the tsconfig at status bar, it's apps/web/tsconfig.vitest.json, but expected same as apps/web/src/main.ts
    image
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Mar 4, 2024
@sheetalkamat
Copy link
Member

This is working as intended per configuration.

When we lookup apps/web/tsconfig.json: main.ts is marked as root of referenced from referenced directly but part of referenced project = { "key": "c:/temp/vite-issue-1815/apps/web/src/main.ts", "value": "c:/temp/vite-issue-1815/apps/web/tsconfig.app.json" } but not app.vue because the config file for referenced projects isnt returning the vue files.. They are part of projects as external files but not as "config" file names which results in discrepancy in how ts files are treated vs vue files.

This can be fixed by plugin by setting extraFileExtentions through ConfigureRequest : https://github.com/microsoft/TypeScript/blob/main/src/server/protocol.ts#L1496

Eg i passed this command to server before opening the file and app.vue works same as main.ts

{ "seq": 1, "type": "request",      "command": "configure", "arguments": { "extraFileExtensions": [{ "extension": ".vue", "isMixedContent": false, "scriptKind": 7 }] }}

@sheetalkamat sheetalkamat added External Relates to another program, environment, or user action which we cannot control. and removed Needs Investigation This issue needs a team member to investigate its status. labels Mar 4, 2024
@codethief
Copy link

@sheetalkamat Tangentially related question: Putting aside *.vue-specific peculiarities, what is the expected outcome when tsconfigs have overlapping includes (like tsconfig.app.json and tsconfig.vitest.json in OP's example)? Which tsconfig ends up being responsible for a given file? Is this documented anywhere?

Background: I have seen overlapping includes in many projects over the last years (in parts due to how create-vue sets up projects by default) and it has always seemed a bit non-deterministic to me which tsconfig ends up being used for a given file.

@sheetalkamat
Copy link
Member

Thes first encountered tsconfig.json or first of its references will be what tsserver will pick as default configured project for "non ts files" that come from plugin and match through include pattern

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

4 participants