-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broken TypeScript syntax highlighting with newest update #4004
Comments
Oh 💩.I think this may have something to do with recent changes to the grammar compiler we use as I can see the language is being correctly detected (Linguist's primary role) but the grammar isn't being applied. Investigating. /cc @vmg cos grammar compiler is my early "off the top of my head" suspicion like the Vue issue previously mentioned. |
From microsoft/TypeScript-TmLanguage#563:
Yup, this appears to be more or less what's happened, though I think we've always used the YAML file. This is comparing one of the test gems I build in the run up to the v6.0.0 release with the v6.0.0 release I can see there is indeed a change: diff --git a/github-linguist-5.3.3.45.g8cf3bf0a/grammars/source.ts.json b/github-linguist-6.0.0/grammars/source.ts.json
index e58ffd2c..258b363a 100644
--- a/github-linguist-5.3.3.45.g8cf3bf0a/grammars/source.ts.json
+++ b/github-linguist-6.0.0/grammars/source.ts.json
@@ -25,7 +25,7 @@
},
"after-operator-block-as-object-literal": {
"name": "meta.objectliteral.ts",
- "begin": "(?\u003c=[=(,\\[?+!]|await|return|yield|throw|in|of|typeof|\u0026\u0026|\\|\\||\\*)\\s*(\\{)",
+ "begin": "(?\u003c=[=(,\\[?+!]|{{lookBehindAwait}}|{{lookBehindReturn}}|{{lookBehindYield}}|{{lookBehindThrow}}|{{lookBehindIn}}|{{lookBehindOf}}|{{lookBehindTypeof}}|\u0026\u0026|\\|\\||\\*)\\s*(\\{)",
"end": "\\}",
"patterns": [
{
@@ -233,7 +233,7 @@
"patterns": [
[... truncated for brevity ...] This example maps to https://github.com/Microsoft/TypeScript-TmLanguage/blob/master/TypeScript.YAML-tmLanguage#L977-L986 It looks like the variables at https://github.com/Microsoft/TypeScript-TmLanguage/blob/0247d1444a66e683bb4005df38218a0fd9576d03/TypeScript.YAML-tmLanguage#L8-L37 weren't interpolated at all. The same thing has happened with the tsx grammar: diff github-linguist-5.3.3.45.g8cf3bf0a/grammars/source.tsx.json github-linguist-6.0.0/grammars/source.tsx.json [email protected]
diff --git a/github-linguist-5.3.3.45.g8cf3bf0a/grammars/source.tsx.json b/github-linguist-6.0.0/grammars/source.tsx.json
index 72d73725..3b4950b1 100644
--- a/github-linguist-5.3.3.45.g8cf3bf0a/grammars/source.tsx.json
+++ b/github-linguist-6.0.0/grammars/source.tsx.json
@@ -236,7 +236,7 @@
"match": "\\S+"
},
"jsx-tag-in-expression": {
- "begin": "(?x)\n (?\u003c=[({\\[,?=\u003e:*]|\u0026\u0026|\\|\\||\\?|\\Wreturn|^return|\\Wdefault|^)\\s*\n (?!\u003c\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s+[^=\u003e])|,)) # look ahead is not type parameter of arrow\n (?=(\u003c)\\s*\n ([_$a-zA-Z][-$\\w.]*(?\u003c!\\.|-))\n (?=\\s+(?!\\?)|/?\u003e))",
+ "begin": "(?x)\n (?\u003c=[({\\[,?=\u003e:*]|\u0026\u0026|\\|\\||\\?|{{lookBehindReturn}}|{{lookBehindDefault}}|^)\\s*\n (?!\u003c\\s*[_$[:alpha:]][_$[:alnum:]]*((\\s+extends\\s+[^=\u003e])|,)) # look ahead is not type parameter of arrow\n (?=(\u003c)\\s*\n ([_$a-zA-Z][-$\\w.]*(?\u003c!\\.|-))\n (?=\\s+(?!\\?)|/?\u003e))",
"end": "(/\u003e)|(?:(\u003c/)\\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?\u003c!\\.|-))\\s*(\u003e))",
"patterns": [
{
@@ -304,7 +304,7 @@
}
},
"jsx-tag-without-attributes-in-expression": {
- "begin": "(?x)\n (?\u003c=[({\\[,?=\u003e:*]|\u0026\u0026|\\|\\||\\?|\\Wreturn|^return|\\Wdefault|^)\\s*\n (?=(\u003c)\\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?\u003c!\\.|-))?\\s*(\u003e))",
+ "begin": "(?x)\n (?\u003c=[({\\[,?=\u003e:*]|\u0026\u0026|\\|\\||\\?|{{lookBehindReturn}}|{{lookBehindDefault}}|^)\\s*\n (?=(\u003c)\\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?\u003c!\\.|-))?\\s*(\u003e))",
"end": "(?!\\s*(\u003c)\\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\\w.]*))(?\u003c!\\.|-))?\\s*(\u003e))",
"patterns": [
{ I can't see anything that changed in Linguist during this time that could explain this. @vmg Did you change something in the compiler or docker image that could explain this? If it helps, I built the test github-linguist-5.3.3.45.g8cf3bf0a.gem on 23 Jan 13:24 GMT. |
Hmmm, looks like microsoft/TypeScript-TmLanguage@53d555b happened within the grammar during that window so I don't think it's a compiler change. Compiling the grammar only produces only a single error/warning:
... though this isn't going to be relevant as that key was there before those changes and already recorded in #3924. So it appears the compiler isn't playing nice with the changes introduced in the commit above. |
And just to confirm, I switched back to the old compiler and it handles this change (superfluous output removed):
So this is def a compiler issue. Over to you @vmg 😉 |
Can you point me to that issue? Couldn't find it here. |
@lildude I've forked the Vue grammar based on TM and made a lot of improvements (even rewrote many sections): https://github.com/vuejs/vetur/commits/master/syntaxes My Vue plugin for VS Code (https://marketplace.visualstudio.com/items?itemName=octref.vetur) has 1.8M downloads and is used by many Vue developers. If https://github.com/vuejs/vue-syntax-highlight is moving forward with a Sublime specific grammar, I suggest you looking into Vetur's grammar as an alternative: https://github.com/vuejs/vetur/tree/master/syntaxes. BTW I can also fix the two outstanding issues for Vue in #3924. |
@octref if your grammar is better and more likely to be actively maintained going forward, please review https://github.com/github/linguist/blob/master/CONTRIBUTING.md#changing-the-source-of-a-syntax-highlighting-grammar and send us a PR to switch the sources. If you could do that ASAP we can use your grammar in the next release that I need to make in the next day or so. |
OK, if I don't have this ready tonight I'll have it by tomorrow noon. |
#4012 does indeed fix this. I'm gonna keep this issue open until GitHub.com has been updated, hopefully sometime tomorrow at the latest. |
Linguist v6.0.1 has now been deployed to GitHub.com and TypeScript syntax highlighting is working again, eg https://github.com/github/linguist/blob/master/samples/TypeScript/classes.ts |
Preliminary Steps
Please confirm you have...
Problem Description
I suspect the update #4002 broke TypeScript syntax highlighting.
I already opened issue at microsoft/TypeScript-TmLanguage#563 here and they confirmed that is not their problem and everything is working as intended.
Screenshots:
https://github.com/SimplrJS/ts-extractor/blob/master/README.md
https://github.com/SimplrJS/ts-extractor/blob/master/src/api-registry.ts
The text was updated successfully, but these errors were encountered: