From 23ed7b98d2934720c5111a6451cb64c1860a0f4a Mon Sep 17 00:00:00 2001 From: Steven Kalt Date: Wed, 13 Nov 2024 16:48:23 -0500 Subject: [PATCH] fix(typescript): highlight string literal type parameters (#1010) Fixes #1009 --- lexers/embedded/typescript.xml | 10 +++++++ lexers/testdata/typescript.actual | 5 ++++ lexers/testdata/typescript.expected | 46 +++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/lexers/embedded/typescript.xml b/lexers/embedded/typescript.xml index 4dff6ec2b..7d541cb6c 100644 --- a/lexers/embedded/typescript.xml +++ b/lexers/embedded/typescript.xml @@ -57,6 +57,16 @@ + + + + + + + + + + diff --git a/lexers/testdata/typescript.actual b/lexers/testdata/typescript.actual index 658147d86..cffabf7be 100644 --- a/lexers/testdata/typescript.actual +++ b/lexers/testdata/typescript.actual @@ -15,4 +15,9 @@ const TestComponent = ({ a, b }) => ( ) +type FirstChar = K extends `${infer X}${infer _}` + ? X + : never +type SChar = FirstChar<"stuff"> + export { TestComponent } \ No newline at end of file diff --git a/lexers/testdata/typescript.expected b/lexers/testdata/typescript.expected index 63e0261dc..bd7196bf8 100644 --- a/lexers/testdata/typescript.expected +++ b/lexers/testdata/typescript.expected @@ -136,6 +136,52 @@ {"type":"Text","value":"\n"}, {"type":"Punctuation","value":")"}, {"type":"Text","value":"\n\n"}, + {"type":"KeywordReserved","value":"type"}, + {"type":"Text","value":" "}, + {"type":"NameOther","value":"FirstChar"}, + {"type":"Punctuation","value":"\u003c"}, + {"type":"NameTag","value":"K"}, + {"type":"Text","value":" "}, + {"type":"NameAttribute","value":"extends"}, + {"type":"Text","value":" "}, + {"type":"NameAttribute","value":"string"}, + {"type":"Punctuation","value":"\u003e"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"NameOther","value":"K"}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"extends"}, + {"type":"Text","value":" "}, + {"type":"LiteralStringBacktick","value":"`"}, + {"type":"LiteralStringInterpol","value":"${"}, + {"type":"Keyword","value":"infer"}, + {"type":"Text","value":" "}, + {"type":"NameOther","value":"X"}, + {"type":"LiteralStringInterpol","value":"}${"}, + {"type":"Keyword","value":"infer"}, + {"type":"Text","value":" "}, + {"type":"NameOther","value":"_"}, + {"type":"LiteralStringInterpol","value":"}"}, + {"type":"LiteralStringBacktick","value":"`"}, + {"type":"Text","value":"\n "}, + {"type":"Operator","value":"?"}, + {"type":"Text","value":" "}, + {"type":"NameOther","value":"X"}, + {"type":"Text","value":"\n : "}, + {"type":"KeywordType","value":"never"}, + {"type":"Text","value":"\n"}, + {"type":"KeywordReserved","value":"type"}, + {"type":"Text","value":" "}, + {"type":"NameOther","value":"SChar"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"NameOther","value":"FirstChar"}, + {"type":"Operator","value":"\u003c"}, + {"type":"LiteralStringDouble","value":"\"stuff\""}, + {"type":"Operator","value":"\u003e"}, + {"type":"Text","value":"\n\n"}, {"type":"KeywordReserved","value":"export"}, {"type":"Text","value":" "}, {"type":"Punctuation","value":"{"},