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