microsoft / TypeScript-TmLanguage

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

syntax highlighting is broken on >3 deep nested generics #969

Closed DetachHead closed 1 year ago

DetachHead commented 1 year ago

TS and JS Grammar Extension version: idk, that link is a 404 but i'm pretty sure it's bundled with vscode? my vscode version is 1.76.0

Code

const foo = <T>(value: T): T => value

const bar = foo<Array<Record<string, Record<string, number>>>>([])

screenshot image

(notice the different colours on the types string and number, and the red >>>)

sheetalkamat commented 1 year ago

This is because of textmate limitation we only have 3 levels of type arguments.

DetachHead commented 1 year ago

@sheetalkamat is there an open issue anywhere for that? Seems like a pretty big limitation especially since TM is used in vscode. As an IDE it should have pretty solid syntax highlighting imo

Would it be possible to use the language server for syntax highlighting instead?

sheetalkamat commented 1 year ago

what I meant was because of how textmate grammar works where we have to determine based on single line syntax to determine if the lookahead is actually function call or "<" etc, we have written rule to lookup 3 levels of type arguments in function call. https://github.com/microsoft/TypeScript-TmLanguage/blob/master/TypeScript.YAML-tmLanguage#L72