Description
TypeScript Version: 3.9.7
PS: I am using Angular and therefor cannot try to use a later version of Typescript at this time.
Search Terms:
PNPM Typescript import slow
System
OS: Windows 10
Disk: SSD
Expected behavior:
When using PNPM or another packagemanager that uses a symlinked node_modules folder, the code Auto Import fixes like "Imports x from modules" and "import all missing imports" are performed within a reasonable delay. Preferably on par with NPM. With NPM as packagemanager, the code fixes "Imports x from modules" or "import all missing imports" are much faster.
Actual behavior:
The upgrade to Angular 10, also upgraded Typescript to version 3.9.7. In 3.9, support for code Auto Import fixes for imports from symlinked node_modules folder were added.
So I replaced npm with pnpm, and yes indeed, code Auto Imports fixes do function, however extremely slow.
In PNPM TSServer.log, you can see I performed 2 actions
- Import OnInit from @angular/core
In Visual Studio Code, the yellow lightblub appeared; I selected OnInit from @angular/core, the import statement was generated after approximately
PNPM: 3 seconds
NPM: < 1 second
PS: Also please note that with NPM, the Yellow Lightblub did not appear but the blue one did.
- Import all missing imports
In Visual Studio Code, I selected a missing import and from the blue lightblub, I selected "Import all missing imports", the import statements were generated after approximately
PNPM: 51 seconds
NPM: 2 seconds
This is the NPM TSServer.log.
When doing each action, CPU was at 100%.
.
Related Issues:
Activity
[-]Typescript: TSServer: Code Fixes: Import missing imports with a symlinked node_modules folder[/-][+]Typescript: TSServer: Code Fixes: Import missing imports with a symlinked node_modules folder is very slow[/+]sheetalkamat commentedon Oct 27, 2020
@frederikdekegel Please provide detailed repro steps along with sample code and auto import to invoke so we can investigate this.
Thanks
frederikdekegel commentedon Nov 1, 2020
Hi @sheetalkamat, for the repro steps, I described the repro steps in the original issue. Is there anything that is not clear? I will add screenshots of my actions for sure.I do not have access to my laptop before tuesday.
As for the code, I can give you my repro, but I do not have experience with github, apart from logging issues. How do I delivery the code to you?
sheetalkamat commentedon Nov 2, 2020
we have made lot of changes to auto import scenarios recently so we want exact repro steps, code to setup and observe difference.
So we want to able to try these steps with latest typescript and precisely.
frederikdekegel commentedon Nov 3, 2020
Hi @sheetalkamat,
Code
I created a private repository, acv-csc-codebase, and I invited you as a collaborator. This should give you access to the code
Steps
Execute npm -g install pnpm
Open Visual Studio Code
In Visual Studio Code, open workspace Apps/ws.code-workspace
In Visual Studio Code, open a terminal
Execute pnpm install
In Visual Studio Code, make sure to use the Workspace version of Typescript, 4.0.5.
In Visual Studio Code, open Apps/acv-csc/apps/contact/src/app/_components/physical-direct-contact-detail/physical-direct-contact-detail.component.ts. This file is missing all of it's imports
Action 1: Add single missing import = In the class definition, there is a text OnInit. Put the cursor inside OnInit. On the left, the lightbulb appears. Select Import OnInit from module "@angular/core".
Note
The codebase already uses typescript 4.0.5. I see some improvement in the speed for action 1 (add single missing import). Action 2, however, remains much slower compared to npm.
sheetalkamat commentedon Nov 4, 2020
Adding @andrewbranch @jessetrinity to see if this is working as intended or something that can be done.
I can see that import fix all does take a while but then there are lot many errors to go through.
39 remaining items
andrewbranch commentedon Jan 4, 2021
@walkerburgin if you wouldn’t mind taking measurements from #42150, that would be great! The last comment from typescript-bot has an npm link you can use.
walkerburgin commentedon Jan 4, 2021
@andrewbranch here's what I'm seeing. Same file and action as before, but a different commit:
Before:

After:

Looks better to me!
rhyek commentedon Jan 27, 2021
Currently using 4.2.0-dev.20210126 and can confirm the fix works.
chore: enable preserveSymlinks
Jack-Works commentedon May 25, 2021
Seems this has partially regressed.
I'm using 4.4.0-dev.20210522
Type
import use
and trigger completion, some of the results are pointing into the.pnpm
folder.If I accept the completion, it will becomes
If I trigger the code fix on undefined
useControlled
, the.pnpm
one appears on the first.andrewbranch commentedon May 25, 2021
Regression was somewhere in #43149. I’ll take a look. Thanks @Jack-Works!
andrewbranch commentedon May 26, 2021
@Jack-Works I was able to recreate some problems like this, but would you mind trying out #44259 to make sure it handles the complexities of a real project?
nwparker commentedon Jan 1, 2022
In ts
4.5.4
this seems broken againandrewbranch commentedon Feb 1, 2022
@nwparker can you share a repro?