language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Auto-import in JSDoc always uses `ts` behaviour

Open Ilanaya opened this issue 1 year ago • 1 comments

Vue - Official extension or vue-tsc version

v2.0.26

VSCode version

1.91.0

Vue version

latest

TypeScript version

5.5.2

System Info

No response

Steps to reproduce

In reproduction repo:

  1. Open exampleLangJs.vue
  2. Trigger import suggestions on MyType JSDoc comment

image

  1. Accept first entry

What is expected?

Imports from JSDoc in <script lang="js">/ <script> work like in regular js file:

You can check this in reproduction repo:

  1. Without @import comment image image

  2. With @import comment image image

What is actually happening?

Whole d.ts/ts file is imported

image

Link to minimal reproduction

https://github.com/ilanaya/volar-starter

Any additional comments?

No response

Ilanaya avatar Jul 12 '24 13:07 Ilanaya

I think this is caused by TS getNewImportFixes function identifying the .js extension instead of LanguageServiceHost.getScriptKind. https://github.com/microsoft/TypeScript/blob/903e82b368c8328dba95b70b21415e7a48339857/src/services/codefixes/importFixes.ts#L1168

johnsoncodehk avatar Jul 22 '24 02:07 johnsoncodehk

Please track https://github.com/microsoft/TypeScript/pull/62840 and consider reopening an issue in the TypeScript repository, thanks.

johnsoncodehk avatar Dec 04 '25 20:12 johnsoncodehk