microsoft / TypeScript

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

Typescript type checker gets stuck #46227

Open Jason3S opened 2 years ago

Jason3S commented 2 years ago

TS Template added by @mjbvz

TypeScript Version: 4.5.0-dev.20211005

Search Terms


Issue Type: Bug

Please note: I tried this using the TypeScript playground, but was not able to get it to happen.

Create a new TypeScript file:

test.ts

/**
 * Sample class
 */
export class MyClass {
    private resolvedWords = new Map<string, string>();
    constructor(readonly words: string[]) {}
}

Type the following line: private known = new Map<string, string>(); above private resolvedWords = new Map<string, string>(); It is important to type the line and not paste it.

Results in an error that will not go away: image

image

It is not possible to "fix" the error that is not an error. The type checker seems to be stuck.

The only solution is to close the file and reopen it: image

VS Code version: Code 1.60.2 (7f6ab5485bbc008386c4386d08766667e155244e, 2021-09-22T11:59:27.195Z) OS version: Darwin x64 20.6.0 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (16 x 2300)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|2, 3, 2| |Memory (System)|32.00GB (0.62GB free)| |Process Argv|Spell Checker.code-workspace --crash-reporter-id 21ae0ece-62a2-4681-a5cf-c687ea23e753| |Screen Reader|no| |VM|0%|
Extensions (50) Extension|Author (truncated)|Version ---|---|--- terraform|4op|0.2.2 ada|Ada|22.0.11 commit-message-editor|ada|0.19.1 alignment|ann|0.3.0 vscode-zipfs|arc|2.3.0 vscode-intelephense-client|bme|1.7.1 better-toml|bun|0.3.2 scala|dal|0.0.5 vscode-eslint|dba|2.1.25 gitlens-insiders|eam|2021.10.405 EditorConfig|Edi|0.16.4 vscode-npm-script|eg2|0.3.22 prettier-vscode|esb|9.0.0 vscode-graphql|Gra|0.3.18 mediawiki|jak|2.1.0 latex-workshop|Jam|8.20.2 svg|joc|1.4.12 language-haskell|jus|3.4.0 vscode-cfml|Kam|0.5.3 linter-gfortran|krv|2.3.0 remotefs|lix|0.0.16 Kotlin|mat|1.7.1 vscode-apache|mrm|1.2.0 vscode-puglint|mrm|2.3.0 vscode-docker|ms-|1.17.0 python|ms-|2021.9.1246542782 vscode-pylance|ms-|2021.9.4 jupyter|ms-|2021.8.2041215044 jupyter-keymap|ms-|1.0.0 remote-containers|ms-|0.194.3 azure-account|ms-|0.9.9 cpptools|ms-|1.6.0 vsonline|ms-|1.0.3076 marko|pca|0.4.0 java|red|0.82.0 es6-mocha-snippets|spo|0.2.2 avro|str|0.5.0 code-spell-checker|str|2.0.8 code-spell-checker-dutch|str|0.2.9 code-spell-checker-german|str|2.0.1 code-spell-checker-persian|str|0.1.9 code-spell-checker-portuguese-brazilian|str|2.0.2 code-spell-checker-russian|str|2.0.1 code-spell-checker-spanish|str|2.0.2 code-spell-checker-swedish|str|1.0.1 code-spell-checker-turkish|str|0.1.9 code-spell-checker-ukrainian|str|0.1.10 hunspell|str|0.0.2 vscodeintellicode|Vis|1.2.14 vscode-java-debug|vsc|0.36.0
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 pythonvspyt602:30300191 vspor879:30202332 vspor708:30202333 vspor363:30204092 pythonvspyt639:30300192 pythontb:30283811 pythonvspyt551cf:30345471 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscorecescf:30358481 pythondataviewer:30285071 pythonvsuse255:30340121 vscod805:30301674 pythonvspyt200:30340761 binariesv615:30325510 vsccppwtct:30364498 pythonvssor306:30344512 bridge0708:30335490 pygetstartedt2:30371810 dockerwalkthru:30370836 bridge0723:30353136 pythonrunftest32:30373476 pythonf5test824:30373475 javagetstartedc:30364665 pythonvspyt187:30373474 pydsgsc2:30361791 vsqsis400:30374798 vsaa593:30376534 ```
mjbvz commented 2 years ago

Please describe the issue

Also does this reproduce in the latest VS Code insiders build with all extensions disabled?

Jason3S commented 2 years ago

@mjbvz, I have updated the description with better steps and images.

Jason3S commented 2 years ago

@mjbvz it also breaks on the latest insiders build.

image

Version: 1.61.0-insider Commit: c9e8266ee24f34107ff52d836a4e8f533afb93c5 Date: 2021-10-01T14:47:05.989Z Electron: 13.5.0 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Darwin x64 20.6.0

mjbvz commented 2 years ago

Thanks. I'm not able to reproduce this though. Have you tested with all extensions disabled to confirm that one of them is not causing the issue?

Also, does this happen in all project you work with, or only in one project in particular?

Jason3S commented 2 years ago

I have create a simple repo:

Jason3S/vscode-issue-134386

I have tried it with and without extensions. It happens in every case.

Note: I have discovered that if I delete the line that I typed, it seems to reset the type system.

mjbvz commented 2 years ago

Thanks! The key is pausing for a moment on the closing >. After that, I can reproduce the issue.

Here are the logs: tsserver.log

stickyfingies commented 2 years ago

Can confirm, I've experienced this issue as well. Deleting the key or value type in the Map generic parameters and re-typing them usually fixes the issue.

sandersn commented 2 years ago

Doesn't repro on emacs, so I suspect that diffing the list of requests sent to the server would help.

CWSpear commented 2 years ago

Mongoose (somewhat) recently introduced some types that have been massively slowing down a lot of users' TypeScript experience. I don't know if that helps anyone here.

https://github.com/Automattic/mongoose/issues/10349