microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.08k stars 12.37k forks source link

Go to definition/Go to Type definition items in right click menu do not respect typesVersions #58714

Closed jroru closed 1 month ago

jroru commented 3 months ago

Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce:

  1. Install a dependency that includes multiple versions of declaration files via typesVersions (e.g. @types/react)
  2. Install a version of typescript that meets the condition of a typesVersions entry (e.g. > 5 in the case of @types/react)
  3. Right click on the import of the dependency (e.g. import { memo } from "react";) and click go to definition
  4. Be taken to the incorrect types version
IllusionMH commented 3 months ago

What file do you expect? BTW condition is <=5.0, not >5.0 as it looks in your post.

In VS Code with built-in TS 5.4.5 - it correctly navigates to node_modules/@types/react/index.d.ts If local 4.9.5 or 5.0.4 used - it correctly navigates to node_modules/@types/react/ts5.0/index.d.ts

If that's not what you see - you should provide more details about expectations and configurations.

And you can try tsc --traceResolution to see how TS resolves definition for that package.

RyanCavanaugh commented 2 months ago

We need a concrete repo here; prose instructions are not precise enough to know what exactly you were doing