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) @type
47 (#match? @type "^[A-Z]"))
48(type_identifier) @type
49(predefined_type) @type.builtin
50
51([
52 (identifier)
53 (shorthand_property_identifier)
54 (shorthand_property_identifier_pattern)
55 ] @constant
56 (#match? @constant "^_*[A-Z_][A-Z\\d_]*$"))
57
58; Literals
59
60(this) @variable.special
61(super) @variable.special
62
63[
64 (null)
65 (undefined)
66] @constant.builtin
67
68[
69 (true)
70 (false)
71] @boolean
72
73(comment) @comment
74
75[
76 (string)
77 (template_string)
78] @string
79
80(regex) @string.regex
81(number) @number
82
83; Tokens
84
85[
86 ";"
87 "?."
88 "."
89 ","
90 ":"
91] @punctuation.delimiter
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 "||="
137 "??="
138] @operator
139
140[
141 "("
142 ")"
143 "["
144 "]"
145 "{"
146 "}"
147] @punctuation.bracket
148
149[
150 "as"
151 "async"
152 "await"
153 "break"
154 "case"
155 "catch"
156 "class"
157 "const"
158 "continue"
159 "debugger"
160 "default"
161 "delete"
162 "do"
163 "else"
164 "export"
165 "extends"
166 "finally"
167 "for"
168 "from"
169 "function"
170 "get"
171 "if"
172 "import"
173 "in"
174 "instanceof"
175 "let"
176 "new"
177 "of"
178 "return"
179 "set"
180 "static"
181 "switch"
182 "target"
183 "throw"
184 "try"
185 "typeof"
186 "var"
187 "void"
188 "while"
189 "with"
190 "yield"
191] @keyword
192
193(template_substitution
194 "${" @punctuation.special
195 "}" @punctuation.special) @embedded
196
197(type_arguments
198 "<" @punctuation.bracket
199 ">" @punctuation.bracket)
200
201; Keywords
202
203[ "abstract"
204 "declare"
205 "enum"
206 "export"
207 "implements"
208 "interface"
209 "keyof"
210 "namespace"
211 "private"
212 "protected"
213 "public"
214 "type"
215 "readonly"
216 "override"
217] @keyword