1; Variables
2
3(identifier) @variable
4
5(call_expression
6 function: (member_expression
7 object: (identifier) @type
8 (#any-of?
9 @type
10 "Promise"
11 "Array"
12 "Object"
13 "Map"
14 "Set"
15 "WeakMap"
16 "WeakSet"
17 "Date"
18 "Error"
19 "TypeError"
20 "RangeError"
21 "SyntaxError"
22 "ReferenceError"
23 "EvalError"
24 "URIError"
25 "RegExp"
26 "Function"
27 "Number"
28 "String"
29 "Boolean"
30 "Symbol"
31 "BigInt"
32 "Proxy"
33 "ArrayBuffer"
34 "DataView"
35 )
36 )
37)
38
39; Properties
40
41(property_identifier) @property
42(shorthand_property_identifier) @property
43(shorthand_property_identifier_pattern) @property
44(private_property_identifier) @property
45
46; Function and method calls
47
48(call_expression
49 function: (identifier) @function)
50
51(call_expression
52 function: (member_expression
53 property: [(property_identifier) (private_property_identifier)] @function.method))
54
55(new_expression
56 constructor: (identifier) @type)
57
58(nested_type_identifier
59 module: (identifier) @type)
60
61; Function and method definitions
62
63(function_expression
64 name: (identifier) @function)
65(function_declaration
66 name: (identifier) @function)
67(method_definition
68 name: [(property_identifier) (private_property_identifier)] @function.method)
69(method_definition
70 name: (property_identifier) @constructor
71 (#eq? @constructor "constructor"))
72
73(pair
74 key: [(property_identifier) (private_property_identifier)] @function.method
75 value: [(function_expression) (arrow_function)])
76
77(assignment_expression
78 left: (member_expression
79 property: [(property_identifier) (private_property_identifier)] @function.method)
80 right: [(function_expression) (arrow_function)])
81
82(variable_declarator
83 name: (identifier) @function
84 value: [(function_expression) (arrow_function)])
85
86(assignment_expression
87 left: (identifier) @function
88 right: [(function_expression) (arrow_function)])
89
90; Parameters
91
92(required_parameter
93 (identifier) @variable.parameter)
94
95(required_parameter
96 (_
97 ([
98 (identifier)
99 (shorthand_property_identifier_pattern)
100 ]) @variable.parameter))
101
102(optional_parameter
103 (identifier) @variable.parameter)
104
105(optional_parameter
106 (_
107 ([
108 (identifier)
109 (shorthand_property_identifier_pattern)
110 ]) @variable.parameter))
111
112(catch_clause
113 parameter: (identifier) @variable.parameter)
114
115(index_signature
116 name: (identifier) @variable.parameter)
117
118(arrow_function
119 parameter: (identifier) @variable.parameter)
120
121; Special identifiers
122;
123(class_declaration
124 (type_identifier) @type.class)
125
126(extends_clause
127 value: (identifier) @type.class)
128
129(type_identifier) @type
130(predefined_type) @type.builtin
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
141(this) @variable.special
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(regex_flags) @keyword.operator.regex
167(number) @number
168
169; Tokens
170
171[
172 ";"
173 "?."
174 "."
175 ","
176 ":"
177] @punctuation.delimiter
178
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] @operator
226
227(regex "/" @string.regex)
228
229[
230 "("
231 ")"
232 "["
233 "]"
234 "{"
235 "}"
236] @punctuation.bracket
237
238(ternary_expression
239 [
240 "?"
241 ":"
242 ] @operator
243)
244
245[
246 "abstract"
247 "as"
248 "async"
249 "await"
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 "break"
297 "case"
298 "catch"
299 "continue"
300 "do"
301 "else"
302 "finally"
303 "for"
304 "if"
305 "return"
306 "switch"
307 "throw"
308 "try"
309 "while"
310 "yield"
311] @keyword.control
312
313(switch_default "default" @keyword.control)
314
315(template_substitution
316 "${" @punctuation.special
317 "}" @punctuation.special) @embedded
318
319(type_arguments
320 "<" @punctuation.bracket
321 ">" @punctuation.bracket)
322
323(decorator "@" @punctuation.special)
324
325; JSX elements
326(jsx_opening_element
327 [
328 (identifier) @type
329 (member_expression
330 object: (identifier) @type
331 property: (property_identifier) @type
332 )
333 ]
334)
335(jsx_closing_element
336 [
337 (identifier) @type
338 (member_expression
339 object: (identifier) @type
340 property: (property_identifier) @type
341 )
342 ]
343)
344(jsx_self_closing_element
345 [
346 (identifier) @type
347 (member_expression
348 object: (identifier) @type
349 property: (property_identifier) @type
350 )
351 ]
352)
353
354(jsx_opening_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
355(jsx_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
356(jsx_self_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
357(jsx_attribute (property_identifier) @attribute.jsx)
358(jsx_opening_element (["<" ">"]) @punctuation.bracket.jsx)
359(jsx_closing_element (["</" ">"]) @punctuation.bracket.jsx)
360(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket.jsx)
361(jsx_attribute "=" @punctuation.delimiter.jsx)
362(jsx_text) @text.jsx
363(html_character_reference) @string.special