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 @@ <rule pattern=","> <token type="Punctuation"/> </rule> + <rule pattern=""(\\\\|\\"|[^"])*""> + <token type="LiteralStringDouble"/> + </rule> + <rule pattern="'(\\\\|\\'|[^'])*'"> + <token type="LiteralStringSingle"/> + </rule> + <rule pattern="`"> + <token type="LiteralStringBacktick"/> + <push state="interp"/> + </rule> <rule> <include state="commentsandwhitespace"/> </rule> 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 }) => ( </Component> ) +type FirstChar<K extends string> = 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":"{"},