microsoft / TypeScript

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

TypeScript import suggestion not showing symlinked modules #37414

Open 5argon opened 4 years ago

5argon commented 4 years ago

TS Template added by @mjbvz

TypeScript Version: 3.8.3

Search Terms


ts-yarnv2-symlink.zip Issue Type: Bug

Open the included project and run yarn at root to initialize everything. This is a yarn V2 workspace project with node_modules linker, allowing a monorepo to gather its sub-packages to the top level node_modules to reference together. You can see here that node_modules has ws1 and ws2 of the inner packages.

Screenshot 2020-03-16 00 39 04

Go to file p1.ts that attempts to use p2Function from an another package. I have put the dependency in package.json as well. Try to call the import suggestion and it is not aware of possible choice.

Screenshot 2020-03-16 00 39 13

Uncomment the first line and see that the line works, and go to definition works. Therefore, the suggestion has a bug that can't take symlinked packages in account. Moving the p2.ts file into p2/index.ts didn't enable the suggestion either.

Screenshot 2020-03-16 00 39 18

VS Code version: Code 1.43.0 (78a4c91400152c0f27ba4d363eb56d2835f9903a, 2020-03-09T19:34:44.548Z) OS version: Darwin x64 19.3.0

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-5287U CPU @ 2.90GHz (4 x 2900)| |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: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled| |Load (avg)|11, 18, 17| |Memory (System)|8.00GB (0.08GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
Extensions (38) Extension|Author (truncated)|Version ---|---|--- svelte-intellisense|ard|0.7.1 npm-intellisense|chr|1.3.0 mustache|daw|1.1.1 dotnet-test-explorer|for|0.7.1 svelte-vscode|Jam|0.9.3 vscode-edit-csv|jan|0.2.6 vscode-peacock|joh|3.6.0 docomment|k--|0.1.8 graphql-for-vscode|kum|1.15.3 Kotlin|mat|1.7.1 vscode-clang|mit|0.2.3 HTMLHint|mka|0.6.0 lc3-assembly|mke|0.1.5 csharp|ms-|1.21.14 cpptools|ms-|0.26.3 Go|ms-|0.13.1 color-highlight|nau|2.3.0 language-liquid|nei|0.1.1 much-assembly-required-language-support|PJB|0.1.5 java|red|0.58.0 postcss|ric|2.0.0 text-marker|ryu|1.11.0 vscode-bolt-language|smk|0.0.4 ayu|tea|0.18.0 vsfire|tob|1.4.1 ink|tom|0.1.0 sort-lines|Tyr|1.9.0 unity-debug|Uni|2.7.3 vscodeintellicode|Vis|1.2.6 vscode-java-debug|vsc|0.25.1 vscode-java-dependency|vsc|0.9.0 vscode-java-pack|vsc|0.8.1 vscode-java-test|vsc|0.22.2 vscode-maven|vsc|0.21.1 vim|vsc|1.13.0 better-align|wwm|1.1.6 vscode-surround|yat|1.0.2 vscode-proto3|zxh|0.4.2 (34 theme extensions excluded)
mjbvz commented 4 years ago

Seems like a duplicate of https://github.com/microsoft/TypeScript/issues/36460#issuecomment-578945287?

5argon commented 4 years ago

Hi, no. I have disabled PnP in this case to return to regular node_modules. I understand that PnP won't work because they are zip files rather than source codes. But in this case they are all source codes.

The line in .yarnrc.yml enables this built in plugin, which disable PnP and add back regular node_modules

https://github.com/yarnpkg/berry/tree/master/packages/plugin-node-modules

2020年3月17日(火) 0:13 Matt Bierner notifications@github.com:

Seems like a duplicate of #36460 (comment) https://github.com/microsoft/TypeScript/issues/36460#issuecomment-578945287 ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/microsoft/TypeScript/issues/37414#issuecomment-599658179, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLEGHBRYYL34VO3L7RWUQLRHZM3PANCNFSM4LMOQR6A .

deejayy commented 3 years ago

Bump. Since my work drive is not that big I had to move all node_modules in a different (disposable, also faster) drive. Typescript now can't find any of the imports (e.g. trying to import combineLatest from rxjs). Without symlinks, so placing node_modules in the actual project folder everything works fine. What am I missing?

FunkMonkey commented 2 years ago

I have the same problem using yarn v1 / npm workspaces. Interestingly, once a file from another module (e.g. b-module/some-file.ts) has been imported at least once in a file in another module (a-module) the auto-imports work for b-module/some-file.ts work everywhere in a-module, but the other definitions in b-module still dont work.