1; Variables
  2
  3(identifier) @variable
  4
  5; Special identifiers
  6
  7((identifier) @type
  8 (#match? @type "^[A-Z]"))
  9(type_identifier) @type
 10(predefined_type) @type.builtin
 11
 12(import_specifier
 13  "type"
 14  name: (identifier) @type
 15  alias: (identifier) @type
 16)
 17
 18(import_statement
 19  "type"
 20  (import_clause
 21    (named_imports
 22      (import_specifier
 23        name: (identifier) @type
 24        alias: (identifier) @type
 25      )
 26    )
 27  )
 28)
 29
 30([
 31  (identifier)
 32  (shorthand_property_identifier)
 33  (shorthand_property_identifier_pattern)
 34 ] @constant
 35 (#match? @constant "^_*[A-Z_][A-Z\\d_]*$"))
 36
 37; Properties
 38
 39(property_identifier) @property
 40(shorthand_property_identifier) @property
 41(shorthand_property_identifier_pattern) @property
 42(private_property_identifier) @property
 43
 44; Function and method calls
 45
 46(call_expression
 47  function: (identifier) @function)
 48
 49(call_expression
 50  function: (member_expression
 51    property: [(property_identifier) (private_property_identifier)] @function.method))
 52
 53; Function and method definitions
 54
 55(function_expression
 56  name: (identifier) @function)
 57(function_declaration
 58  name: (identifier) @function)
 59(method_definition
 60  name: [(property_identifier) (private_property_identifier)] @function.method)
 61(method_definition
 62    name: (property_identifier) @constructor
 63    (#eq? @constructor "constructor"))
 64
 65(pair
 66  key: [(property_identifier) (private_property_identifier)] @function.method
 67  value: [(function_expression) (arrow_function)])
 68
 69(assignment_expression
 70  left: (member_expression
 71    property: [(property_identifier) (private_property_identifier)] @function.method)
 72  right: [(function_expression) (arrow_function)])
 73
 74(variable_declarator
 75  name: (identifier) @function
 76  value: [(function_expression) (arrow_function)])
 77
 78(assignment_expression
 79  left: (identifier) @function
 80  right: [(function_expression) (arrow_function)])
 81
 82; Literals
 83
 84(this) @variable.special
 85(super) @variable.special
 86
 87[
 88  (null)
 89  (undefined)
 90] @constant.builtin
 91
 92[
 93  (true)
 94  (false)
 95] @boolean
 96
 97(literal_type
 98  [
 99    (null)
100    (undefined)
101    (true)
102    (false)
103  ] @type.builtin
104)
105
106(comment) @comment
107
108(hash_bang_line) @comment
109
110[
111  (string)
112  (template_string)
113  (template_literal_type)
114] @string
115
116(escape_sequence) @string.escape
117
118(regex) @string.regex
119(regex_flags) @keyword.operator.regex
120(number) @number
121
122; Tokens
123
124[
125  ";"
126  "?."
127  "."
128  ","
129  ":"
130  "?"
131] @punctuation.delimiter
132
133[
134  "..."
135  "-"
136  "--"
137  "-="
138  "+"
139  "++"
140  "+="
141  "*"
142  "*="
143  "**"
144  "**="
145  "/"
146  "/="
147  "%"
148  "%="
149  "<"
150  "<="
151  "<<"
152  "<<="
153  "="
154  "=="
155  "==="
156  "!"
157  "!="
158  "!=="
159  "=>"
160  ">"
161  ">="
162  ">>"
163  ">>="
164  ">>>"
165  ">>>="
166  "~"
167  "^"
168  "&"
169  "|"
170  "^="
171  "&="
172  "|="
173  "&&"
174  "||"
175  "??"
176  "&&="
177  "||="
178  "??="
179  "..."
180] @operator
181
182(regex "/" @string.regex)
183
184(ternary_expression
185  [
186    "?"
187    ":"
188  ] @operator
189)
190
191[
192  "("
193  ")"
194  "["
195  "]"
196  "{"
197  "}"
198]  @punctuation.bracket
199
200(template_substitution
201  "${" @punctuation.special
202  "}" @punctuation.special) @embedded
203
204(template_type
205  "${" @punctuation.special
206  "}" @punctuation.special) @embedded
207
208(type_arguments
209  "<" @punctuation.bracket
210  ">" @punctuation.bracket)
211
212(decorator "@" @punctuation.special)
213
214; Keywords
215
216[
217  "abstract"
218  "as"
219  "async"
220  "await"
221  "class"
222  "const"
223  "debugger"
224  "declare"
225  "default"
226  "delete"
227  "enum"
228  "export"
229  "extends"
230  "from"
231  "function"
232  "get"
233  "implements"
234  "import"
235  "in"
236  "infer"
237  "instanceof"
238  "interface"
239  "is"
240  "keyof"
241  "let"
242  "module"
243  "namespace"
244  "new"
245  "of"
246  "override"
247  "private"
248  "protected"
249  "public"
250  "readonly"
251  "satisfies"
252  "set"
253  "static"
254  "target"
255  "type"
256  "typeof"
257  "using"
258  "var"
259  "void"
260  "with"
261] @keyword
262
263[
264  "break"
265  "case"
266  "catch"
267  "continue"
268  "do"
269  "else"
270  "finally"
271  "for"
272  "if"
273  "return"
274  "switch"
275  "throw"
276  "try"
277  "while"
278  "yield"
279] @keyword.control
280
281(switch_default "default" @keyword.control)