microsoft / TypeScript-TmLanguage

TextMate grammar files for TypeScript for VS Code, Sublime Text, and Atom.
MIT License
398 stars 125 forks source link

Typescript tokenization fails on methods with return type = `typeof thing` #882

Closed ghost closed 2 years ago

ghost commented 2 years ago

Issue Type: Bug

I'm guessing this belongs in some sub-project, but I don't know where.

class A {
  method(): typeof x {
    // entire function body is seen as a type definition and provides no syntax highlighting.  Sometimes falls through to subsequent methods as well
    console.log('whatever');
  }
}

VS Code version: Code 1.59.1 (Universal) (3866c3553be8b268c8a7f8c0482c0c0177aa8bfa, 2021-08-19T11:53:52.479Z) OS version: Darwin x64 20.6.0 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)| |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, 2, 2| |Memory (System)|32.00GB (0.27GB free)| |Process Argv|. --crash-reporter-id 09193da5-1d91-4e7e-99fc-e528b5899fd1| |Screen Reader|no| |VM|0%|
Extensions (16) Extension|Author (truncated)|Version ---|---|--- vscode-zipfs|arc|2.3.0 vscode-eslint|dba|2.1.23 prettier-vscode|esb|8.1.0 svg|joc|1.4.9 nite|jom|1.0.0 vscode-docker|ms-|1.16.0 remote-containers|ms-|0.191.1 remote-ssh|ms-|0.65.7 remote-ssh-edit|ms-|0.65.7 sublime-keybindings|ms-|4.0.9 vscode-typescript-next|ms-|4.5.20210822 autoimport|ste|1.5.4 errorlens|use|3.4.0 wallaby-vscode|Wal|1.0.309 material-theme|zhu|3.11.4 vscode-proto3|zxh|0.5.4 (3 theme extensions excluded)
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383cf:30185419 pythonvspyt602:30300191 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492cf:30256860 pythonvspyt639:30300192 pythontb:30283811 pythonvspyt551:30345470 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 pythondataviewer:30285071 pythonvsuse255:30340121 vscod805:30301674 pythonvspyt200:30340761 vscextlangct:30333562 binariesv615:30325510 pythonvssor306:30344512 bridge0708:30335490 vstre464:30350172 bridge0723:30353136 javagetstartedc:30351792 vsdyn321cf:30354108 ```
IllusionMH commented 2 years ago

/needsMoreInfo

Is it reproducible with all extensions disabled? You can try this with F1 and >Developer: Reload Window With Extensions Disabled

This one looks like duplicate of https://github.com/microsoft/TypeScript-TmLanguage/issues/858 (and other issue in repo) which was fixed couple of versions ago

Screenshots with difference with/without typeof would be also helpful.

Unable to reproduce it in 1.59.1 while it's obvious in 1.55.1 image

/assign @mjbvz is it possible that vscode-typescript-next breaks highlight here?

ghost commented 2 years ago

Whoops, I thought I did reload with extensions disabled, must have done something else accidentally.

It's apparently caused by vscode-typescript-next, as you suspected. Should I open the issue against that project or does it belong here?

screenshots:

image image
mjbvz commented 2 years ago

Should be fixed by https://github.com/microsoft/vscode-typescript-next/commit/b59a12cce39a4e7ee32178645cb0eb0229a0f116