Binaryify / OneDark-Pro

Atom's iconic One Dark theme for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=zhuangtongfa.Material-theme
MIT License
1.48k stars 291 forks source link

Wrong formatting in Typescript when using generics with `extends` and type parameters #804

Closed ricardofrancoli closed 9 months ago

ricardofrancoli commented 9 months ago

Describe the bug Formatting in Typescript is off when using const arrow function with <{genericType} extends {type<{typeParameters}>}>, e.g.: <T extends Test<1 | 2>>

To Reproduce Steps to reproduce the behavior:

  1. Create an arrow function that utilises Typescript generics with type parameters, e.g.:
    
    type Test<T extends 1 | 2> = { a: T; b: T }

const getSorted = <T extends Test<1 | 2>>(something: T[], order: 'asc' | 'desc') => { return something .sort((someA, someB) => { if (order === 'desc') { return someA.a - someB.b } else { return someB.a - someA.b } }) .slice(0, 3) }



**Expected behavior**
The formatting should be different:
- `return`s and `else` should be purple instead of yellow
- `===` should be blue instead of grey
- `if` should be purple instead of blue
- the numbers inside the `sort` should be orange instead of grey

**Screenshots & Example Code**
Here's the bug, using a `Test` type with generic type parameters:
![Screenshot 2023-10-24 at 11 34 18](https://github.com/Binaryify/OneDark-Pro/assets/59377210/667ae3f0-8568-4fbc-aebf-95aa584a5fe2)

Using `function` instead works fine:
![Screenshot 2023-10-24 at 11 33 53](https://github.com/Binaryify/OneDark-Pro/assets/59377210/3ac15a7d-0676-4e4b-98e1-c868dbd8389c)

And using an arrow function with a simpler type, without the `<{typeParameters}>` works too:
![Screenshot 2023-10-24 at 11 35 34](https://github.com/Binaryify/OneDark-Pro/assets/59377210/1f0dd8e7-0a2a-4350-8f2c-5d82e0a9cd00)

**Desktop (please complete the following information):**
 - OS: macOS 14.0 (23A344)
 - VSCODE: 
Version: 1.83.1
Commit: f1b07bd25dfad64b0167beb15359ae573aecd2cc
Date: 2023-10-10T23:57:32.750Z
Electron: 25.8.4
ElectronBuildId: 24154031
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 23.0.0
 - Theme version: v3.16.2 (One Dark Pro Flat)
ricardofrancoli commented 9 months ago

Apologies, this also happens with other themes. Must be something wrong with VSCode/my settings.