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; Special identifiers
121;
122(type_identifier) @type
123
124(predefined_type) @type.builtin
125
126(class_declaration
127 (type_identifier) @type.class)
128
129(extends_clause
130 value: (identifier) @type.class)
131
132([
133 (identifier)
134 (shorthand_property_identifier)
135 (shorthand_property_identifier_pattern)
136] @constant
137 (#match? @constant "^_*[A-Z_][A-Z\\d_]*$"))
138
139; Literals
140(this) @variable.special
141
142(super) @variable.special
143
144[
145 (null)
146 (undefined)
147] @constant.builtin
148
149[
150 (true)
151 (false)
152] @boolean
153
154(comment) @comment
155
156(hash_bang_line) @comment
157
158[
159 (string)
160 (template_string)
161] @string
162
163(escape_sequence) @string.escape
164
165(regex) @string.regex
166
167(regex_flags) @keyword.operator.regex
168
169(number) @number
170
171; Tokens
172[
173 ";"
174 "?."
175 "."
176 ","
177 ":"
178] @punctuation.delimiter
179
180[
181 "-"
182 "--"
183 "-="
184 "+"
185 "++"
186 "+="
187 "*"
188 "*="
189 "**"
190 "**="
191 "/"
192 "/="
193 "%"
194 "%="
195 "<"
196 "<="
197 "<<"
198 "<<="
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] @operator
227
228(regex
229 "/" @string.regex)
230
231[
232 "("
233 ")"
234 "["
235 "]"
236 "{"
237 "}"
238] @punctuation.bracket
239
240(ternary_expression
241 [
242 "?"
243 ":"
244 ] @operator)
245
246[
247 "abstract"
248 "as"
249 "async"
250 "debugger"
251 "declare"
252 "default"
253 "delete"
254 "extends"
255 "get"
256 "implements"
257 "in"
258 "instanceof"
259 "keyof"
260 "module"
261 "namespace"
262 "new"
263 "of"
264 "override"
265 "private"
266 "protected"
267 "public"
268 "readonly"
269 "set"
270 "static"
271 "target"
272 "typeof"
273 "using"
274 "void"
275 "with"
276] @keyword
277
278[
279 "const"
280 "let"
281 "var"
282 "function"
283 "class"
284 "enum"
285 "interface"
286 "type"
287] @keyword.declaration
288
289[
290 "export"
291 "from"
292 "import"
293] @keyword.import
294
295[
296 "await"
297 "break"
298 "case"
299 "catch"
300 "continue"
301 "do"
302 "else"
303 "finally"
304 "for"
305 "if"
306 "return"
307 "switch"
308 "throw"
309 "try"
310 "while"
311 "yield"
312] @keyword.control
313
314(switch_default
315 "default" @keyword.control)
316
317(template_substitution
318 "${" @punctuation.special
319 "}" @punctuation.special) @embedded
320
321(type_arguments
322 "<" @punctuation.bracket
323 ">" @punctuation.bracket)
324
325(decorator
326 "@" @punctuation.special)
327
328; JSX elements
329(jsx_opening_element
330 [
331 (identifier) @type @tag.component.jsx
332 (member_expression
333 object: (identifier) @type @tag.component.jsx
334 property: (property_identifier) @type @tag.component.jsx)
335 (member_expression
336 object: (member_expression
337 object: (identifier) @type @tag.component.jsx
338 property: (property_identifier) @type @tag.component.jsx)
339 property: (property_identifier) @type @tag.component.jsx)
340 (member_expression
341 object: (member_expression
342 object: (member_expression
343 object: (identifier) @type @tag.component.jsx
344 property: (property_identifier) @type @tag.component.jsx)
345 property: (property_identifier) @type @tag.component.jsx)
346 property: (property_identifier) @type @tag.component.jsx)
347 ])
348
349(jsx_closing_element
350 [
351 (identifier) @type @tag.component.jsx
352 (member_expression
353 object: (identifier) @type @tag.component.jsx
354 property: (property_identifier) @type @tag.component.jsx)
355 (member_expression
356 object: (member_expression
357 object: (identifier) @type @tag.component.jsx
358 property: (property_identifier) @type @tag.component.jsx)
359 property: (property_identifier) @type @tag.component.jsx)
360 (member_expression
361 object: (member_expression
362 object: (member_expression
363 object: (identifier) @type @tag.component.jsx
364 property: (property_identifier) @type @tag.component.jsx)
365 property: (property_identifier) @type @tag.component.jsx)
366 property: (property_identifier) @type @tag.component.jsx)
367 ])
368
369(jsx_self_closing_element
370 [
371 (identifier) @type @tag.component.jsx
372 (member_expression
373 object: (identifier) @type @tag.component.jsx
374 property: (property_identifier) @type @tag.component.jsx)
375 (member_expression
376 object: (member_expression
377 object: (identifier) @type @tag.component.jsx
378 property: (property_identifier) @type @tag.component.jsx)
379 property: (property_identifier) @type @tag.component.jsx)
380 (member_expression
381 object: (member_expression
382 object: (member_expression
383 object: (identifier) @type @tag.component.jsx
384 property: (property_identifier) @type @tag.component.jsx)
385 property: (property_identifier) @type @tag.component.jsx)
386 property: (property_identifier) @type @tag.component.jsx)
387 ])
388
389(jsx_opening_element
390 (identifier) @tag.jsx
391 (#match? @tag.jsx "^[a-z][^.]*$"))
392
393(jsx_closing_element
394 (identifier) @tag.jsx
395 (#match? @tag.jsx "^[a-z][^.]*$"))
396
397(jsx_self_closing_element
398 (identifier) @tag.jsx
399 (#match? @tag.jsx "^[a-z][^.]*$"))
400
401(jsx_attribute
402 (property_identifier) @attribute.jsx)
403
404(jsx_opening_element
405 ([
406 "<"
407 ">"
408 ]) @punctuation.bracket.jsx)
409
410(jsx_closing_element
411 ([
412 "</"
413 ">"
414 ]) @punctuation.bracket.jsx)
415
416(jsx_self_closing_element
417 ([
418 "<"
419 "/>"
420 ]) @punctuation.bracket.jsx)
421
422(jsx_attribute
423 "=" @punctuation.delimiter.jsx)
424
425(jsx_text) @text.jsx
426
427(html_character_reference) @string.special