microsoft / TypeScript-TmLanguage

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

Syntax highlighting breaks with newline between type variables in TypeScript #919

Closed uloco closed 1 year ago

uloco commented 2 years ago

Does this issue occur when all extensions are disabled?: Yes

Version: 1.68.1 Commit: 30d9c6cd9483b2cc586687151bcbcd635f373630 Date: 2022-06-14T12:48:37.209Z Electron: 17.4.7 Chromium: 98.0.4758.141 Node.js: 16.13.0 V8: 9.8.177.13-electron.0 OS: Darwin arm64 21.5.0

Steps to Reproduce:

  1. Copy the following code as it is in your editor. (Do not reformat!)
const api = { doWhatever: <T, U>(arg: T | U) => { console.log(arg); }, };

// works
api.doWhatever<string, number>("arg");

// broken
api.doWhatever<
  string,
  number
>("arg");

// works
const obj1 = {
  nested: () => ({
    func: api.doWhatever<string, Record<string,any>>({})
  })};

// broken
const obj2 = {
  nested: () => ({
    func: api.doWhatever<
      string,
      Record<string,any>
      >({})
  })};
  1. See the broken highlighting in the places where the types in the angle brackets are spread over mulitple lines.
  2. Punctuation scopes and type highlighting is only correct when the angle brackets are in one line.
  3. If you can, use Bluloco Dark theme, because on the default theme the scopes are not clearly different. You can check the scopes on the punctuation marks and types manually though. They are no longer detected correctly. See my screenshot below:
Screenshot 2022-07-06 at 21 16 07
uloco commented 2 years ago

BTW I also tried latest Insiders build, with no extensions enabled, still the same issue. See the scopes here for easier debugging:

Screenshot 2022-07-06 at 21 41 49 Screenshot 2022-07-06 at 21 42 24
BernardoMariano commented 1 year ago

Am facing the exact same issue

image image image
sheetalkamat commented 1 year ago

Duplicate of #475