microsoft / TypeScript-TmLanguage

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

Tokens after `instanceof` are not highlighted correctly #921

Closed qingpeng9802 closed 1 year ago

qingpeng9802 commented 2 years ago

Code

children0 instanceof Child === true;
children0 instanceof Child.prototype.constructor === true;
children0 instanceof(Child.prototype.constructor) === true;
children0 instanceof dict.CONST.ctor === true;

Current highlighting: image

Expected highlighting: image

Reason: The set of termination characters is incomplete so '#type' will leaks to the end of line in some cases. https://github.com/microsoft/TypeScript-TmLanguage/blob/0dfae8cc4807fecfbf8f1add095d9817df824c95/TypeScript.YAML-tmLanguage#L57

Also, '#type' is kind of aggressive for instanceof, we should probably use a behavior similar to extends to get more accurate highlighting on properties, https://github.com/microsoft/TypeScript-TmLanguage/blob/0dfae8cc4807fecfbf8f1add095d9817df824c95/TypeScript.YAML-tmLanguage#L1563-L1569 https://github.com/microsoft/TypeScript-TmLanguage/blob/0dfae8cc4807fecfbf8f1add095d9817df824c95/TypeScript.YAML-tmLanguage#L948-L969

A PR will be linked.