mirror of
https://github.com/alecthomas/chroma.git
synced 2025-03-17 20:58:08 +02:00
fix(typescript): highlight string literal type parameters (#1010)
Fixes #1009
This commit is contained in:
parent
e76e1e2233
commit
23ed7b98d2
@ -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>
|
||||
|
5
lexers/testdata/typescript.actual
vendored
5
lexers/testdata/typescript.actual
vendored
@ -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 }
|
46
lexers/testdata/typescript.expected
vendored
46
lexers/testdata/typescript.expected
vendored
@ -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":"{"},
|
||||
|
Loading…
x
Reference in New Issue
Block a user