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
43; Function and method calls
44
45(call_expression
46 function: (identifier) @function)
47
48(call_expression
49 function: (member_expression
50 property: (property_identifier) @function.method))
51
52; Function and method definitions
53
54(function_expression
55 name: (identifier) @function)
56(function_declaration
57 name: (identifier) @function)
58(method_definition
59 name: (property_identifier) @function.method)
60
61(pair
62 key: (property_identifier) @function.method
63 value: [(function_expression) (arrow_function)])
64
65(assignment_expression
66 left: (member_expression
67 property: (property_identifier) @function.method)
68 right: [(function_expression) (arrow_function)])
69
70(variable_declarator
71 name: (identifier) @function
72 value: [(function_expression) (arrow_function)])
73
74(assignment_expression
75 left: (identifier) @function
76 right: [(function_expression) (arrow_function)])
77
78; Literals
79
80(this) @keyword
81(super) @keyword
82
83[
84 (null)
85 (undefined)
86] @constant.builtin
87
88[
89 (true)
90 (false)
91] @boolean
92
93(literal_type
94 [
95 (null)
96 (undefined)
97 (true)
98 (false)
99 ] @type.builtin
100)
101
102(comment) @comment
103
104[
105 (string)
106 (template_string)
107 (template_literal_type)
108] @string
109
110(escape_sequence) @string.escape
111
112(regex) @string.regex
113(number) @number
114
115; Tokens
116
117[
118 "..."
119 "-"
120 "--"
121 "-="
122 "+"
123 "++"
124 "+="
125 "*"
126 "*="
127 "**"
128 "**="
129 "/"
130 "/="
131 "%"
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] @operator
164
165(ternary_expression
166 [
167 "?"
168 ":"
169 ] @operator
170)
171
172[
173 ";"
174 "?."
175 "."
176 ","
177 ":"
178 "?"
179] @punctuation.delimiter
180
181[
182 "("
183 ")"
184 "["
185 "]"
186 "{"
187 "}"
188] @punctuation.bracket
189
190(template_substitution
191 "${" @punctuation.special
192 "}" @punctuation.special) @embedded
193
194(template_type
195 "${" @punctuation.special
196 "}" @punctuation.special) @embedded
197
198(type_arguments
199 "<" @punctuation.bracket
200 ">" @punctuation.bracket)
201
202; Keywords
203
204[
205 "abstract"
206 "as"
207 "async"
208 "await"
209 "break"
210 "case"
211 "catch"
212 "class"
213 "const"
214 "continue"
215 "debugger"
216 "declare"
217 "default"
218 "delete"
219 "do"
220 "else"
221 "enum"
222 "export"
223 "extends"
224 "finally"
225 "for"
226 "from"
227 "function"
228 "get"
229 "if"
230 "implements"
231 "import"
232 "in"
233 "infer"
234 "instanceof"
235 "interface"
236 "is"
237 "keyof"
238 "let"
239 "namespace"
240 "new"
241 "of"
242 "override"
243 "private"
244 "protected"
245 "public"
246 "readonly"
247 "return"
248 "satisfies"
249 "set"
250 "static"
251 "switch"
252 "target"
253 "throw"
254 "try"
255 "type"
256 "typeof"
257 "using"
258 "var"
259 "void"
260 "while"
261 "with"
262 "yield"
263] @keyword