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 "await"
251 "debugger"
252 "declare"
253 "default"
254 "delete"
255 "extends"
256 "get"
257 "implements"
258 "in"
259 "instanceof"
260 "keyof"
261 "module"
262 "namespace"
263 "new"
264 "of"
265 "override"
266 "private"
267 "protected"
268 "public"
269 "readonly"
270 "set"
271 "static"
272 "target"
273 "typeof"
274 "using"
275 "void"
276 "with"
277] @keyword
278
279[
280 "const"
281 "let"
282 "var"
283 "function"
284 "class"
285 "enum"
286 "interface"
287 "type"
288] @keyword.declaration
289
290[
291 "export"
292 "from"
293 "import"
294] @keyword.import
295
296[
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
332 (member_expression
333 object: (identifier) @type
334 property: (property_identifier) @type)
335 ])
336
337(jsx_closing_element
338 [
339 (identifier) @type
340 (member_expression
341 object: (identifier) @type
342 property: (property_identifier) @type)
343 ])
344
345(jsx_self_closing_element
346 [
347 (identifier) @type
348 (member_expression
349 object: (identifier) @type
350 property: (property_identifier) @type)
351 ])
352
353(jsx_opening_element
354 (identifier) @tag.jsx
355 (#match? @tag.jsx "^[a-z][^.]*$"))
356
357(jsx_closing_element
358 (identifier) @tag.jsx
359 (#match? @tag.jsx "^[a-z][^.]*$"))
360
361(jsx_self_closing_element
362 (identifier) @tag.jsx
363 (#match? @tag.jsx "^[a-z][^.]*$"))
364
365(jsx_attribute
366 (property_identifier) @attribute.jsx)
367
368(jsx_opening_element
369 ([
370 "<"
371 ">"
372 ]) @punctuation.bracket.jsx)
373
374(jsx_closing_element
375 ([
376 "</"
377 ">"
378 ]) @punctuation.bracket.jsx)
379
380(jsx_self_closing_element
381 ([
382 "<"
383 "/>"
384 ]) @punctuation.bracket.jsx)
385
386(jsx_attribute
387 "=" @punctuation.delimiter.jsx)
388
389(jsx_text) @text.jsx
390
391(html_character_reference) @string.special