1; Variables
2(identifier) @variable
3
4(call_expression
5 function: (member_expression
6 object: (identifier) @type
7 (#any-of? @type
8 "Promise" "Array" "Object" "Map" "Set" "WeakMap" "WeakSet" "Date" "Error" "TypeError"
9 "RangeError" "SyntaxError" "ReferenceError" "EvalError" "URIError" "RegExp" "Function"
10 "Number" "String" "Boolean" "Symbol" "BigInt" "Proxy" "ArrayBuffer" "DataView")))
11
12; Properties
13(property_identifier) @property
14
15(shorthand_property_identifier) @property
16
17(shorthand_property_identifier_pattern) @property
18
19(private_property_identifier) @property
20
21; Function and method calls
22(call_expression
23 function: (identifier) @function)
24
25(call_expression
26 function: (member_expression
27 property: [
28 (property_identifier)
29 (private_property_identifier)
30 ] @function.method))
31
32(new_expression
33 constructor: (identifier) @type)
34
35(nested_type_identifier
36 module: (identifier) @type)
37
38; Function and method definitions
39(function_expression
40 name: (identifier) @function)
41
42(function_declaration
43 name: (identifier) @function)
44
45(method_definition
46 name: [
47 (property_identifier)
48 (private_property_identifier)
49 ] @function.method)
50
51(method_definition
52 name: (property_identifier) @constructor
53 (#eq? @constructor "constructor"))
54
55(pair
56 key: [
57 (property_identifier)
58 (private_property_identifier)
59 ] @function.method
60 value: [
61 (function_expression)
62 (arrow_function)
63 ])
64
65(assignment_expression
66 left: (member_expression
67 property: [
68 (property_identifier)
69 (private_property_identifier)
70 ] @function.method)
71 right: [
72 (function_expression)
73 (arrow_function)
74 ])
75
76(variable_declarator
77 name: (identifier) @function
78 value: [
79 (function_expression)
80 (arrow_function)
81 ])
82
83(assignment_expression
84 left: (identifier) @function
85 right: [
86 (function_expression)
87 (arrow_function)
88 ])
89
90; Parameters
91(required_parameter
92 (identifier) @variable.parameter)
93
94(required_parameter
95 (_
96 ([
97 (identifier)
98 (shorthand_property_identifier_pattern)
99 ]) @variable.parameter))
100
101(optional_parameter
102 (identifier) @variable.parameter)
103
104(optional_parameter
105 (_
106 ([
107 (identifier)
108 (shorthand_property_identifier_pattern)
109 ]) @variable.parameter))
110
111(catch_clause
112 parameter: (identifier) @variable.parameter)
113
114(index_signature
115 name: (identifier) @variable.parameter)
116
117(arrow_function
118 parameter: (identifier) @variable.parameter)
119
120(type_predicate
121 name: (identifier) @variable.parameter)
122
123; Special identifiers
124(type_annotation) @type
125
126(type_identifier) @type
127
128(predefined_type) @type.builtin
129
130(type_alias_declaration
131 (type_identifier) @type)
132
133(type_alias_declaration
134 value: (_
135 (type_identifier) @type))
136
137(interface_declaration
138 (type_identifier) @type)
139
140(class_declaration
141 (type_identifier) @type.class)
142
143(extends_clause
144 value: (identifier) @type.class)
145
146(extends_type_clause
147 type: (type_identifier) @type)
148
149(implements_clause
150 (type_identifier) @type)
151
152([
153 (identifier)
154 (shorthand_property_identifier)
155 (shorthand_property_identifier_pattern)
156] @constant
157 (#match? @constant "^_*[A-Z_][A-Z\\d_]*$"))
158
159; Literals
160(this) @variable.special
161
162(super) @variable.special
163
164[
165 (null)
166 (undefined)
167] @constant.builtin
168
169[
170 (true)
171 (false)
172] @boolean
173
174(comment) @comment
175
176[
177 (string)
178 (template_string)
179 (template_literal_type)
180] @string
181
182(escape_sequence) @string.escape
183
184(regex) @string.regex
185
186(regex_flags) @keyword.operator.regex
187
188(number) @number
189
190; Tokens
191[
192 ";"
193 "?."
194 "."
195 ","
196 ":"
197 "?"
198] @punctuation.delimiter
199
200[
201 "-"
202 "--"
203 "-="
204 "+"
205 "++"
206 "+="
207 "*"
208 "*="
209 "**"
210 "**="
211 "/"
212 "/="
213 "%"
214 "%="
215 "<"
216 "<="
217 "<<"
218 "<<="
219 "="
220 "=="
221 "==="
222 "!"
223 "!="
224 "!=="
225 "=>"
226 ">"
227 ">="
228 ">>"
229 ">>="
230 ">>>"
231 ">>>="
232 "~"
233 "^"
234 "&"
235 "|"
236 "^="
237 "&="
238 "|="
239 "&&"
240 "||"
241 "??"
242 "&&="
243 "||="
244 "??="
245 "..."
246] @operator
247
248(regex
249 "/" @string.regex)
250
251[
252 "("
253 ")"
254 "["
255 "]"
256 "{"
257 "}"
258] @punctuation.bracket
259
260(ternary_expression
261 [
262 "?"
263 ":"
264 ] @operator)
265
266; Keywords
267[
268 "abstract"
269 "as"
270 "async"
271 "await"
272 "debugger"
273 "declare"
274 "default"
275 "delete"
276 "extends"
277 "get"
278 "implements"
279 "in"
280 "infer"
281 "instanceof"
282 "is"
283 "keyof"
284 "module"
285 "namespace"
286 "new"
287 "of"
288 "override"
289 "private"
290 "protected"
291 "public"
292 "readonly"
293 "satisfies"
294 "set"
295 "static"
296 "target"
297 "typeof"
298 "using"
299 "void"
300 "with"
301] @keyword
302
303[
304 "const"
305 "let"
306 "var"
307 "function"
308 "class"
309 "enum"
310 "interface"
311 "type"
312] @keyword.declaration
313
314[
315 "export"
316 "from"
317 "import"
318] @keyword.import
319
320[
321 "break"
322 "case"
323 "catch"
324 "continue"
325 "do"
326 "else"
327 "finally"
328 "for"
329 "if"
330 "return"
331 "switch"
332 "throw"
333 "try"
334 "while"
335 "yield"
336] @keyword.control
337
338(switch_default
339 "default" @keyword.control)
340
341(template_substitution
342 "${" @punctuation.special
343 "}" @punctuation.special) @embedded
344
345(template_type
346 "${" @punctuation.special
347 "}" @punctuation.special) @embedded
348
349(type_arguments
350 "<" @punctuation.bracket
351 ">" @punctuation.bracket)
352
353(type_parameters
354 "<" @punctuation.bracket
355 ">" @punctuation.bracket)
356
357(decorator
358 "@" @punctuation.special)
359
360(union_type
361 "|" @punctuation.special)
362
363(intersection_type
364 "&" @punctuation.special)
365
366(type_annotation
367 ":" @punctuation.special)
368
369(index_signature
370 ":" @punctuation.special)
371
372(type_predicate_annotation
373 ":" @punctuation.special)
374
375(public_field_definition
376 "?" @punctuation.special)
377
378(property_signature
379 "?" @punctuation.special)
380
381(method_signature
382 "?" @punctuation.special)
383
384(optional_parameter
385 ([
386 "?"
387 ":"
388 ]) @punctuation.special)
389
390(jsx_opening_element
391 [
392 (identifier) @type
393 (member_expression
394 object: (identifier) @type
395 property: (property_identifier) @type)
396 ])
397
398(jsx_closing_element
399 [
400 (identifier) @type
401 (member_expression
402 object: (identifier) @type
403 property: (property_identifier) @type)
404 ])
405
406(jsx_self_closing_element
407 [
408 (identifier) @type
409 (member_expression
410 object: (identifier) @type
411 property: (property_identifier) @type)
412 ])
413
414(jsx_opening_element
415 (identifier) @tag.jsx
416 (#match? @tag.jsx "^[a-z][^.]*$"))
417
418(jsx_closing_element
419 (identifier) @tag.jsx
420 (#match? @tag.jsx "^[a-z][^.]*$"))
421
422(jsx_self_closing_element
423 (identifier) @tag.jsx
424 (#match? @tag.jsx "^[a-z][^.]*$"))
425
426(jsx_attribute
427 (property_identifier) @attribute.jsx)
428
429(jsx_opening_element
430 ([
431 "<"
432 ">"
433 ]) @punctuation.bracket.jsx)
434
435(jsx_closing_element
436 ([
437 "</"
438 ">"
439 ]) @punctuation.bracket.jsx)
440
441(jsx_self_closing_element
442 ([
443 "<"
444 "/>"
445 ]) @punctuation.bracket.jsx)
446
447(jsx_attribute
448 "=" @punctuation.delimiter.jsx)
449
450(jsx_text) @text.jsx
451
452(html_character_reference) @string.special