Debian Codegraph @

runtime/queries/_typescript/highlights.scm

raw symbols SCIP
1 ; Namespaces
2 ; ----------
3
4 (internal_module
5 [((identifier) @namespace) ((nested_identifier (identifier) @namespace))])
6
7 (ambient_declaration "global" @namespace)
8
9 ; Parameters
10 ; ----------
11 ; Javascript and Typescript Treesitter grammars deviate when defining the
12 ; tree structure for parameters, so we need to address them in each specific
13 ; language instead of ecma.
14
15 ; (p: t)
16 ; (p: t = 1)
17 (required_parameter
18 (identifier) @variable.parameter)
19
20 ; (...p: t)
21 (required_parameter
22 (rest_pattern
23 (identifier) @variable.parameter))
24
25 ; ({ p }: { p: t })
26 (required_parameter
27 (object_pattern
28 (shorthand_property_identifier_pattern) @variable.parameter))
29
30 ; ({ a: p }: { a: t })
31 (required_parameter
32 (object_pattern
33 (pair_pattern
34 value: (identifier) @variable.parameter)))
35
36 ; ([ p ]: t[])
37 (required_parameter
38 (array_pattern
39 (identifier) @variable.parameter))
40
41 ; (p?: t)
42 ; (p?: t = 1) // Invalid but still possible to highlight.
43 (optional_parameter
44 (identifier) @variable.parameter)
45
46 ; (...p?: t) // Invalid but still possible to highlight.
47 (optional_parameter
48 (rest_pattern
49 (identifier) @variable.parameter))
50
51 ; ({ p }: { p?: t})
52 (optional_parameter
53 (object_pattern
54 (shorthand_property_identifier_pattern) @variable.parameter))
55
56 ; ({ a: p }: { a?: t })
57 (optional_parameter
58 (object_pattern
59 (pair_pattern
60 value: (identifier) @variable.parameter)))
61
62 ; ([ p ]?: t[]) // Invalid but still possible to highlight.
63 (optional_parameter
64 (array_pattern
65 (identifier) @variable.parameter))
66
67 (public_field_definition) @punctuation.special
68 (this_type) @variable.builtin
69 (type_predicate) @keyword.operator
70
71 ; Punctuation
72 ; -----------
73
74 [
75 ":"
76 ] @punctuation.delimiter
77
78 (optional_parameter "?" @punctuation.special)
79 (property_signature "?" @punctuation.special)
80
81 (conditional_type ["?" ":"] @operator)
82 (ternary_expression ["?" ":"] @operator)
83
84 ; Keywords
85 ; --------
86
87 [
88 "abstract"
89 "accessor"
90 "declare"
91 "module"
92 "infer"
93 "implements"
94 "keyof"
95 "namespace"
96 "override"
97 "satisfies"
98 "using"
99 ] @keyword
100
101 ; `asserts` in a return-type type predicate, e.g. `function f(x): asserts x is T`
102 "asserts" @keyword.operator
103
104 [
105 "export"
106 "from"
107 ] @keyword.control.import
108
109 [
110 "type"
111 "interface"
112 "enum"
113 ] @keyword.storage.type
114
115 [
116 "public"
117 "private"
118 "protected"
119 "readonly"
120 ] @keyword.storage.modifier
121
122 ; Types
123 ; -----
124
125 (type_identifier) @type
126 (type_parameter
127 name: (type_identifier) @type.parameter)
128 (predefined_type) @type.builtin
129
130 ; Type arguments and parameters
131 ; -----------------------------
132
133 (type_arguments
134 [
135 "<"
136 ">"
137 ] @punctuation.bracket)
138
139 (type_parameters
140 [
141 "<"
142 ">"
143 ] @punctuation.bracket)
144
145 (omitting_type_annotation) @punctuation.special
146 (opting_type_annotation) @punctuation.special
147
148 ; Literals
149 ; --------
150
151 [
152 (template_literal_type)
153 ] @string
154
155 (import_require_clause
156 (identifier) "="
157 ("require") @keyword)
158
159 ; Method signatures in interfaces / type literals, and function-typed
160 ; property signatures (`foo(): void`, `bar: () => void`).
161 (method_signature
162 name: (property_identifier) @function.method)
163 (abstract_method_signature
164 name: (property_identifier) @function.method)
165 (property_signature
166 name: (property_identifier) @function.method
167 type: (type_annotation
168 [
169 (function_type)
170 (union_type (parenthesized_type (function_type)))
171 ]))