Skip to content

Go to Definition refers to VSCode node_modules instead of project's node_modules #110631

Closed

Description

Issue Type: Bug

I'm working on an Angular 9 project and was working on a feature where I needed the bind() method. Currently we have Typescript 3.7.5 which has the following interface in their Function interface:

bind(this: Function, thisArg: any, ...argArray: any[]): any;

This made the return type as any which led to an error in my editor. I thought this was a mistake since this was a "resolved" issue (microsoft/TypeScript#212) in a 2018 PR (microsoft/TypeScript#27028) of a previous TypeScript version. (Still don't know why in this 3.7.5 version bind() returns any if it was resolved 2 years ago but that's another issue...)

So, I tried deleting node_modules, and (just to experiment) I tried +Clicking on the bind() method and it redirected me to the node_modules/typescript definition inside VSCode app contents. You can see the path in this image.

VSCode refering to it's node_modules typescript version definition:
VSCode refering to it's node_modules typescript version definition

This made the initial error disappeared (which is bad) and that's because VSCode has a different TypeScript version: "typescript": "^4.1.0-dev.20201018" which has a different interface for bind() and actually returns the method's type correctly:

bind<T>(this: T, thisArg: ThisParameterType<T>): OmitThisParameter<T>;

Then I did an npm install to get my project's node_modules again, I tried +Clicking again but now it always refers to VSCODE node_modules instead of the project's node_modules.

I've opened multiple Angular projects and does the same thing.

Also, I disabled all extensions and this still happens.

Steps to Reproduce:

I can't reproduce the issue because I can't make it work in order to make it happen again but starting from step 3 this is what I did:

  1. Create an Angular project with TypeScript 3.7.5 (Setup 1/2)
  2. Run npm install (Setup 2/2)
  3. Write a function which has a bind method (although I think it could be any Typescript definition)
  4. +Click Should work well and refer to the project's node_modules
  5. Delete node_modules folder
  6. +Click again and should refer to VSCode node_modules
  7. Try npm install and +Click again and should still refer to VSCode node_modules
VS Code version: Code 1.51.1 (e5a624b788d92b8d34d1392e4c4d9789406efe8f, 2020-11-11T01:11:34.018Z)
Commit: e5a624b788d92b8d34d1392e4c4d9789406efe8f
Date: 2020-11-11T01:11:34.018Z
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS version: Darwin x64 19.6.0
System Info
Item Value
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 1, 2, 2
Memory (System) 64.00GB (44.52GB free)
Process Argv -psn_0_53261 --crash-reporter-id 3470d9bf-740d-480c-9373-b5fb05183146
Screen Reader no
VM 0%
Extensions: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

*as-designedDescribed behavior is as designedinfo-neededIssue requires more information from postertypescriptTypescript support issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions