@willbooster/tree-sitter-typescript 1.2.5 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/common/defineGrammar.js +32 -17
- package/javascript/queries/highlights-jsx.scm +8 -0
- package/javascript/queries/highlights.scm +218 -0
- package/javascript/queries/injections.scm +31 -0
- package/javascript/queries/locals.scm +23 -0
- package/javascript/queries/tags.scm +99 -0
- package/package.json +4 -2
- package/queries/highlights.scm +35 -0
- package/queries/locals.scm +2 -0
- package/queries/tags.scm +23 -0
- package/tree-sitter-tsx.wasm +0 -0
- package/tree-sitter-typescript.wasm +0 -0
- package/tree-sitter.json +21 -15
- package/tsx/src/node-types.json +5 -5
- package/typescript/src/node-types.json +5 -5
package/README.md
CHANGED
|
@@ -67,7 +67,9 @@ const parser = new Parser();
|
|
|
67
67
|
parser.setLanguage(await Language.load(typescript));
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
The package also ships the node types in `typescript/src/node-types.json` and `tsx/src/node-types.json
|
|
70
|
+
The package also ships the node types in `typescript/src/node-types.json` and `tsx/src/node-types.json`, and the
|
|
71
|
+
highlighting, injection, locals, and tags queries that `tree-sitter.json` lists: this grammar's in `queries/` and, in
|
|
72
|
+
`javascript/queries/`, those of the JavaScript grammar it extends.
|
|
71
73
|
|
|
72
74
|
In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-typescript) and on
|
|
73
75
|
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
|
|
@@ -86,6 +88,8 @@ parser.set_language(&tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into())?;
|
|
|
86
88
|
// or `tree_sitter_typescript::LANGUAGE_TSX` for TSX
|
|
87
89
|
```
|
|
88
90
|
|
|
91
|
+
The crate ships the same `tree-sitter.json` and query files as the npm package.
|
|
92
|
+
|
|
89
93
|
## Development
|
|
90
94
|
|
|
91
95
|
```sh
|
|
@@ -116,6 +120,10 @@ cargo test
|
|
|
116
120
|
- a performance check (`test/unit/performance.test.ts`) that recovering from an error on each of 10,000 lines takes
|
|
117
121
|
linear time with each grammar, since consumers parse files while they are being edited. It loads the Wasm builds
|
|
118
122
|
through @willbooster/web-tree-sitter, which `bun run build/ci` rebuilds after regenerating the parsers;
|
|
123
|
+
- a check (`test/unit/queries.test.ts`) that the queries `tree-sitter.json` lists compile against each grammar, are
|
|
124
|
+
published in the npm package and the crate, and that `javascript/queries/` matches the queries of the installed
|
|
125
|
+
@willbooster/tree-sitter-javascript; after updating that dependency, `script/copy-javascript-queries` refreshes the
|
|
126
|
+
copies;
|
|
119
127
|
- checks that both Wasm builds load and parse through @willbooster/web-tree-sitter in Chromium
|
|
120
128
|
(`test/unit/browser/`) and in Cloudflare Workers with and without Node.js compatibility
|
|
121
129
|
(`test/unit/workers.test.ts`, running the Worker in `test/fixtures/worker/`).
|
package/common/defineGrammar.js
CHANGED
|
@@ -242,7 +242,7 @@ module.exports = function defineGrammar(dialect) {
|
|
|
242
242
|
prec(
|
|
243
243
|
'generic_call',
|
|
244
244
|
seq(
|
|
245
|
-
field('function',
|
|
245
|
+
field('function', $.primary_expression),
|
|
246
246
|
field('type_arguments', $.type_arguments),
|
|
247
247
|
field('arguments', choice($.arguments, $.template_string))
|
|
248
248
|
)
|
|
@@ -251,7 +251,7 @@ module.exports = function defineGrammar(dialect) {
|
|
|
251
251
|
prec(
|
|
252
252
|
'template_call',
|
|
253
253
|
seq(
|
|
254
|
-
field('function', choice($.primary_expression, $.new_expression)),
|
|
254
|
+
field('function', choice($.primary_expression, alias($._argumentless_new_expression, $.new_expression))),
|
|
255
255
|
field('arguments', $.template_string)
|
|
256
256
|
)
|
|
257
257
|
),
|
|
@@ -266,17 +266,29 @@ module.exports = function defineGrammar(dialect) {
|
|
|
266
266
|
)
|
|
267
267
|
),
|
|
268
268
|
|
|
269
|
+
// As in ECMAScript, a `new` with arguments is a member-level (primary) expression and one without them is not, so a
|
|
270
|
+
// member access, a call, or a further argument list binds to the nearest `new` with arguments: `new new A().b`
|
|
271
|
+
// constructs `new A().b`, and `new new A()(2)` constructs `new A()`.
|
|
269
272
|
new_expression: ($) =>
|
|
270
|
-
prec
|
|
273
|
+
prec(
|
|
271
274
|
'new',
|
|
272
275
|
seq(
|
|
273
276
|
'new',
|
|
274
|
-
field('constructor', $.
|
|
277
|
+
field('constructor', $._new_constructor),
|
|
275
278
|
field('type_arguments', optional($.type_arguments)),
|
|
276
|
-
field('arguments',
|
|
279
|
+
field('arguments', $.arguments)
|
|
277
280
|
)
|
|
278
281
|
),
|
|
279
282
|
|
|
283
|
+
_argumentless_new_expression: ($) =>
|
|
284
|
+
prec.right(
|
|
285
|
+
'new',
|
|
286
|
+
seq('new', field('constructor', $._new_constructor), field('type_arguments', optional($.type_arguments)))
|
|
287
|
+
),
|
|
288
|
+
|
|
289
|
+
_new_constructor: ($) =>
|
|
290
|
+
prec('new', choice($.primary_expression, alias($._argumentless_new_expression, $.new_expression))),
|
|
291
|
+
|
|
280
292
|
assignment_expression: ($) =>
|
|
281
293
|
prec.right(
|
|
282
294
|
'assign',
|
|
@@ -287,18 +299,26 @@ module.exports = function defineGrammar(dialect) {
|
|
|
287
299
|
|
|
288
300
|
_lhs_expression: ($, previous) => choice(previous, $.non_null_expression),
|
|
289
301
|
|
|
290
|
-
primary_expression: ($, previous) => choice(previous, $.non_null_expression),
|
|
302
|
+
primary_expression: ($, previous) => choice(previous, $.non_null_expression, $.new_expression),
|
|
291
303
|
|
|
292
304
|
// If the dialect is regular typescript, we exclude JSX expressions and
|
|
293
305
|
// include type assertions. If the dialect is TSX, we do the opposite.
|
|
294
306
|
expression: ($, previous) => {
|
|
295
|
-
const choices = [
|
|
307
|
+
const choices = [
|
|
308
|
+
$.as_expression,
|
|
309
|
+
$.satisfies_expression,
|
|
310
|
+
$.instantiation_expression,
|
|
311
|
+
$.internal_module,
|
|
312
|
+
alias($._argumentless_new_expression, $.new_expression),
|
|
313
|
+
];
|
|
314
|
+
// A `new` with arguments is a primary expression (see new_expression).
|
|
315
|
+
const members = previous.members.filter((member) => member.name !== 'new_expression');
|
|
296
316
|
|
|
297
317
|
if (dialect === 'typescript') {
|
|
298
318
|
choices.push($.type_assertion);
|
|
299
|
-
choices.push(...
|
|
319
|
+
choices.push(...members.filter((member) => member.name !== '_jsx_element'));
|
|
300
320
|
} else if (dialect === 'tsx') {
|
|
301
|
-
choices.push(...
|
|
321
|
+
choices.push(...members);
|
|
302
322
|
} else {
|
|
303
323
|
throw new Error(`Unknown dialect ${dialect}`);
|
|
304
324
|
}
|
|
@@ -419,7 +439,8 @@ module.exports = function defineGrammar(dialect) {
|
|
|
419
439
|
')'
|
|
420
440
|
),
|
|
421
441
|
|
|
422
|
-
|
|
442
|
+
// TypeScript parses a postfix `!` as part of a member access chain, so `new A!()` constructs `A!`.
|
|
443
|
+
non_null_expression: ($) => prec('member', seq($.primary_expression, '!')),
|
|
423
444
|
|
|
424
445
|
variable_declarator: ($) =>
|
|
425
446
|
choice(
|
|
@@ -565,13 +586,7 @@ module.exports = function defineGrammar(dialect) {
|
|
|
565
586
|
satisfies_expression: ($) => prec.left('binary', seq($.expression, 'satisfies', $.type)),
|
|
566
587
|
|
|
567
588
|
instantiation_expression: ($) =>
|
|
568
|
-
prec.dynamic(
|
|
569
|
-
-1,
|
|
570
|
-
prec(
|
|
571
|
-
'instantiation',
|
|
572
|
-
seq(choice($.primary_expression, $.new_expression), field('type_arguments', $.type_arguments))
|
|
573
|
-
)
|
|
574
|
-
),
|
|
589
|
+
prec.dynamic(-1, prec('instantiation', seq($.primary_expression, field('type_arguments', $.type_arguments)))),
|
|
575
590
|
|
|
576
591
|
class_heritage: ($) => choice(seq($.extends_clause, optional($.implements_clause)), $.implements_clause),
|
|
577
592
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
(jsx_opening_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
|
|
2
|
+
(jsx_closing_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
|
|
3
|
+
(jsx_self_closing_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
|
|
4
|
+
|
|
5
|
+
(jsx_attribute (property_identifier) @attribute)
|
|
6
|
+
(jsx_opening_element (["<" ">"]) @punctuation.bracket)
|
|
7
|
+
(jsx_closing_element (["</" ">"]) @punctuation.bracket)
|
|
8
|
+
(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket)
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
; Variables
|
|
2
|
+
;----------
|
|
3
|
+
|
|
4
|
+
(identifier) @variable
|
|
5
|
+
|
|
6
|
+
; Properties
|
|
7
|
+
;-----------
|
|
8
|
+
|
|
9
|
+
(property_identifier) @property
|
|
10
|
+
|
|
11
|
+
; Function and method definitions
|
|
12
|
+
;--------------------------------
|
|
13
|
+
|
|
14
|
+
(function_expression
|
|
15
|
+
name: (identifier) @function)
|
|
16
|
+
(function_declaration
|
|
17
|
+
name: (identifier) @function)
|
|
18
|
+
(method_definition
|
|
19
|
+
name: (property_identifier) @function.method)
|
|
20
|
+
|
|
21
|
+
(pair
|
|
22
|
+
key: (property_identifier) @function.method
|
|
23
|
+
value: [(function_expression) (arrow_function)])
|
|
24
|
+
|
|
25
|
+
(assignment_expression
|
|
26
|
+
left: (member_expression
|
|
27
|
+
property: (property_identifier) @function.method)
|
|
28
|
+
right: [(function_expression) (arrow_function)])
|
|
29
|
+
|
|
30
|
+
(variable_declarator
|
|
31
|
+
name: (identifier) @function
|
|
32
|
+
value: [(function_expression) (arrow_function)])
|
|
33
|
+
|
|
34
|
+
(assignment_expression
|
|
35
|
+
left: (identifier) @function
|
|
36
|
+
right: [(function_expression) (arrow_function)])
|
|
37
|
+
|
|
38
|
+
; Function and method calls
|
|
39
|
+
;--------------------------
|
|
40
|
+
|
|
41
|
+
(call_expression
|
|
42
|
+
function: (identifier) @function)
|
|
43
|
+
|
|
44
|
+
(call_expression
|
|
45
|
+
function: (member_expression
|
|
46
|
+
property: (property_identifier) @function.method))
|
|
47
|
+
|
|
48
|
+
; Special identifiers
|
|
49
|
+
;--------------------
|
|
50
|
+
|
|
51
|
+
((identifier) @constructor
|
|
52
|
+
(#match? @constructor "^[A-Z]"))
|
|
53
|
+
|
|
54
|
+
([
|
|
55
|
+
(identifier)
|
|
56
|
+
(shorthand_property_identifier)
|
|
57
|
+
(shorthand_property_identifier_pattern)
|
|
58
|
+
] @constant
|
|
59
|
+
(#match? @constant "^[A-Z_][A-Z\\d_]+$"))
|
|
60
|
+
|
|
61
|
+
((identifier) @variable.builtin
|
|
62
|
+
(#match? @variable.builtin "^(arguments|module|console|window|document)$")
|
|
63
|
+
(#is-not? local))
|
|
64
|
+
|
|
65
|
+
((identifier) @function.builtin
|
|
66
|
+
(#eq? @function.builtin "require")
|
|
67
|
+
(#is-not? local))
|
|
68
|
+
|
|
69
|
+
; Literals
|
|
70
|
+
;---------
|
|
71
|
+
|
|
72
|
+
(this) @variable.builtin
|
|
73
|
+
(super) @variable.builtin
|
|
74
|
+
|
|
75
|
+
[
|
|
76
|
+
(true)
|
|
77
|
+
(false)
|
|
78
|
+
(null)
|
|
79
|
+
(undefined)
|
|
80
|
+
] @constant.builtin
|
|
81
|
+
|
|
82
|
+
(comment) @comment
|
|
83
|
+
|
|
84
|
+
[
|
|
85
|
+
(string)
|
|
86
|
+
(template_string)
|
|
87
|
+
] @string
|
|
88
|
+
|
|
89
|
+
(regex) @string.special
|
|
90
|
+
(number) @number
|
|
91
|
+
|
|
92
|
+
; Tokens
|
|
93
|
+
;-------
|
|
94
|
+
|
|
95
|
+
[
|
|
96
|
+
";"
|
|
97
|
+
(optional_chain)
|
|
98
|
+
"."
|
|
99
|
+
","
|
|
100
|
+
] @punctuation.delimiter
|
|
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
|
+
"^="
|
|
139
|
+
"&="
|
|
140
|
+
"|="
|
|
141
|
+
"&&"
|
|
142
|
+
"||"
|
|
143
|
+
"??"
|
|
144
|
+
"&&="
|
|
145
|
+
"||="
|
|
146
|
+
"??="
|
|
147
|
+
] @operator
|
|
148
|
+
|
|
149
|
+
[
|
|
150
|
+
"("
|
|
151
|
+
")"
|
|
152
|
+
"["
|
|
153
|
+
"]"
|
|
154
|
+
"{"
|
|
155
|
+
"}"
|
|
156
|
+
] @punctuation.bracket
|
|
157
|
+
|
|
158
|
+
(template_substitution
|
|
159
|
+
"${" @punctuation.special
|
|
160
|
+
"}" @punctuation.special) @embedded
|
|
161
|
+
|
|
162
|
+
[
|
|
163
|
+
"as"
|
|
164
|
+
"async"
|
|
165
|
+
"await"
|
|
166
|
+
"break"
|
|
167
|
+
"case"
|
|
168
|
+
"catch"
|
|
169
|
+
"class"
|
|
170
|
+
"const"
|
|
171
|
+
"continue"
|
|
172
|
+
"debugger"
|
|
173
|
+
"default"
|
|
174
|
+
"delete"
|
|
175
|
+
"do"
|
|
176
|
+
"else"
|
|
177
|
+
"export"
|
|
178
|
+
"extends"
|
|
179
|
+
"finally"
|
|
180
|
+
"for"
|
|
181
|
+
"from"
|
|
182
|
+
"function"
|
|
183
|
+
"get"
|
|
184
|
+
"if"
|
|
185
|
+
"import"
|
|
186
|
+
"in"
|
|
187
|
+
"instanceof"
|
|
188
|
+
"let"
|
|
189
|
+
"new"
|
|
190
|
+
"of"
|
|
191
|
+
"return"
|
|
192
|
+
"set"
|
|
193
|
+
"static"
|
|
194
|
+
"switch"
|
|
195
|
+
"target"
|
|
196
|
+
"throw"
|
|
197
|
+
"try"
|
|
198
|
+
"typeof"
|
|
199
|
+
"var"
|
|
200
|
+
"void"
|
|
201
|
+
"while"
|
|
202
|
+
"with"
|
|
203
|
+
"yield"
|
|
204
|
+
] @keyword
|
|
205
|
+
|
|
206
|
+
; `default` as a module export name is an identifier node.
|
|
207
|
+
(export_specifier
|
|
208
|
+
name: (identifier) @keyword
|
|
209
|
+
(#eq? @keyword "default"))
|
|
210
|
+
(export_specifier
|
|
211
|
+
alias: (identifier) @keyword
|
|
212
|
+
(#eq? @keyword "default"))
|
|
213
|
+
(import_specifier
|
|
214
|
+
name: (identifier) @keyword
|
|
215
|
+
(#eq? @keyword "default"))
|
|
216
|
+
(namespace_export
|
|
217
|
+
(identifier) @keyword
|
|
218
|
+
(#eq? @keyword "default"))
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
; Parse the contents of tagged template literals using
|
|
2
|
+
; a language inferred from the tag.
|
|
3
|
+
|
|
4
|
+
(call_expression
|
|
5
|
+
function: [
|
|
6
|
+
(identifier) @injection.language
|
|
7
|
+
(member_expression
|
|
8
|
+
property: (property_identifier) @injection.language)
|
|
9
|
+
]
|
|
10
|
+
arguments: (template_string (string_fragment) @injection.content)
|
|
11
|
+
(#set! injection.combined)
|
|
12
|
+
(#set! injection.include-children))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
; Parse regex syntax within regex literals
|
|
16
|
+
|
|
17
|
+
((regex_pattern) @injection.content
|
|
18
|
+
(#set! injection.language "regex"))
|
|
19
|
+
|
|
20
|
+
; Parse JSDoc annotations in comments
|
|
21
|
+
|
|
22
|
+
((comment) @injection.content
|
|
23
|
+
(#set! injection.language "jsdoc"))
|
|
24
|
+
|
|
25
|
+
; Parse Ember/Glimmer/Handlebars/HTMLBars/etc. template literals
|
|
26
|
+
; e.g.: await render(hbs`<SomeComponent />`)
|
|
27
|
+
(call_expression
|
|
28
|
+
function: ((identifier) @_name
|
|
29
|
+
(#eq? @_name "hbs"))
|
|
30
|
+
arguments: ((template_string) @glimmer
|
|
31
|
+
(#offset! @glimmer 0 1 0 -1)))
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
; Scopes
|
|
2
|
+
;-------
|
|
3
|
+
|
|
4
|
+
[
|
|
5
|
+
(statement_block)
|
|
6
|
+
(function_expression)
|
|
7
|
+
(arrow_function)
|
|
8
|
+
(function_declaration)
|
|
9
|
+
(method_definition)
|
|
10
|
+
] @local.scope
|
|
11
|
+
|
|
12
|
+
; Definitions
|
|
13
|
+
;------------
|
|
14
|
+
|
|
15
|
+
(pattern/identifier) @local.definition
|
|
16
|
+
|
|
17
|
+
(variable_declarator
|
|
18
|
+
name: (identifier) @local.definition)
|
|
19
|
+
|
|
20
|
+
; References
|
|
21
|
+
;------------
|
|
22
|
+
|
|
23
|
+
(identifier) @local.reference
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
(
|
|
2
|
+
(comment)* @doc
|
|
3
|
+
.
|
|
4
|
+
(method_definition
|
|
5
|
+
name: (property_identifier) @name) @definition.method
|
|
6
|
+
(#not-eq? @name "constructor")
|
|
7
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
8
|
+
(#select-adjacent! @doc @definition.method)
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
(
|
|
12
|
+
(comment)* @doc
|
|
13
|
+
.
|
|
14
|
+
[
|
|
15
|
+
(class
|
|
16
|
+
name: (_) @name)
|
|
17
|
+
(class_declaration
|
|
18
|
+
name: (_) @name)
|
|
19
|
+
] @definition.class
|
|
20
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
21
|
+
(#select-adjacent! @doc @definition.class)
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
(
|
|
25
|
+
(comment)* @doc
|
|
26
|
+
.
|
|
27
|
+
[
|
|
28
|
+
(function_expression
|
|
29
|
+
name: (identifier) @name)
|
|
30
|
+
(function_declaration
|
|
31
|
+
name: (identifier) @name)
|
|
32
|
+
(generator_function
|
|
33
|
+
name: (identifier) @name)
|
|
34
|
+
(generator_function_declaration
|
|
35
|
+
name: (identifier) @name)
|
|
36
|
+
] @definition.function
|
|
37
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
38
|
+
(#select-adjacent! @doc @definition.function)
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
(
|
|
42
|
+
(comment)* @doc
|
|
43
|
+
.
|
|
44
|
+
(lexical_declaration
|
|
45
|
+
(variable_declarator
|
|
46
|
+
name: (identifier) @name
|
|
47
|
+
value: [(arrow_function) (function_expression)]) @definition.function)
|
|
48
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
49
|
+
(#select-adjacent! @doc @definition.function)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
(
|
|
53
|
+
(comment)* @doc
|
|
54
|
+
.
|
|
55
|
+
(variable_declaration
|
|
56
|
+
(variable_declarator
|
|
57
|
+
name: (identifier) @name
|
|
58
|
+
value: [(arrow_function) (function_expression)]) @definition.function)
|
|
59
|
+
(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
|
|
60
|
+
(#select-adjacent! @doc @definition.function)
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
(assignment_expression
|
|
64
|
+
left: [
|
|
65
|
+
(identifier) @name
|
|
66
|
+
(member_expression
|
|
67
|
+
property: (property_identifier) @name)
|
|
68
|
+
]
|
|
69
|
+
right: [(arrow_function) (function_expression)]
|
|
70
|
+
) @definition.function
|
|
71
|
+
|
|
72
|
+
(pair
|
|
73
|
+
key: (property_identifier) @name
|
|
74
|
+
value: [(arrow_function) (function_expression)]) @definition.function
|
|
75
|
+
|
|
76
|
+
(
|
|
77
|
+
(call_expression
|
|
78
|
+
function: (identifier) @name) @reference.call
|
|
79
|
+
(#not-match? @name "^(require)$")
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
(call_expression
|
|
83
|
+
function: (member_expression
|
|
84
|
+
property: (property_identifier) @name)
|
|
85
|
+
arguments: (_) @reference.call)
|
|
86
|
+
|
|
87
|
+
(new_expression
|
|
88
|
+
constructor: (_) @name) @reference.class
|
|
89
|
+
|
|
90
|
+
(export_statement value: (assignment_expression left: (identifier) @name right: ([
|
|
91
|
+
(number)
|
|
92
|
+
(string)
|
|
93
|
+
(identifier)
|
|
94
|
+
(undefined)
|
|
95
|
+
(null)
|
|
96
|
+
(new_expression)
|
|
97
|
+
(binary_expression)
|
|
98
|
+
(call_expression)
|
|
99
|
+
]))) @definition.constant
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-typescript",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "TypeScript and TSX grammars for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
"tree-sitter.json",
|
|
23
23
|
"typescript/src/node-types.json",
|
|
24
24
|
"tsx/src/node-types.json",
|
|
25
|
+
"queries/*.scm",
|
|
26
|
+
"javascript/queries/*.scm",
|
|
25
27
|
"*.wasm"
|
|
26
28
|
],
|
|
27
29
|
"scripts": {
|
|
@@ -48,7 +50,7 @@
|
|
|
48
50
|
"@vitest/browser-playwright": "5.0.1",
|
|
49
51
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
50
52
|
"@willbooster/oxlint-config": "1.4.8",
|
|
51
|
-
"@willbooster/tree-sitter-javascript": "1.0.
|
|
53
|
+
"@willbooster/tree-sitter-javascript": "1.0.16",
|
|
52
54
|
"@willbooster/wb": "22.13.0",
|
|
53
55
|
"@willbooster/web-tree-sitter": "1.0.7",
|
|
54
56
|
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
; Types
|
|
2
|
+
|
|
3
|
+
(type_identifier) @type
|
|
4
|
+
(predefined_type) @type.builtin
|
|
5
|
+
|
|
6
|
+
((identifier) @type
|
|
7
|
+
(#match? @type "^[A-Z]"))
|
|
8
|
+
|
|
9
|
+
(type_arguments
|
|
10
|
+
"<" @punctuation.bracket
|
|
11
|
+
">" @punctuation.bracket)
|
|
12
|
+
|
|
13
|
+
; Variables
|
|
14
|
+
|
|
15
|
+
(required_parameter (identifier) @variable.parameter)
|
|
16
|
+
(optional_parameter (identifier) @variable.parameter)
|
|
17
|
+
|
|
18
|
+
; Keywords
|
|
19
|
+
|
|
20
|
+
[ "abstract"
|
|
21
|
+
"declare"
|
|
22
|
+
"enum"
|
|
23
|
+
"export"
|
|
24
|
+
"implements"
|
|
25
|
+
"interface"
|
|
26
|
+
"keyof"
|
|
27
|
+
"namespace"
|
|
28
|
+
"private"
|
|
29
|
+
"protected"
|
|
30
|
+
"public"
|
|
31
|
+
"type"
|
|
32
|
+
"readonly"
|
|
33
|
+
"override"
|
|
34
|
+
"satisfies"
|
|
35
|
+
] @keyword
|
package/queries/tags.scm
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
(function_signature
|
|
2
|
+
name: (identifier) @name) @definition.function
|
|
3
|
+
|
|
4
|
+
(method_signature
|
|
5
|
+
name: (property_identifier) @name) @definition.method
|
|
6
|
+
|
|
7
|
+
(abstract_method_signature
|
|
8
|
+
name: (property_identifier) @name) @definition.method
|
|
9
|
+
|
|
10
|
+
(abstract_class_declaration
|
|
11
|
+
name: (type_identifier) @name) @definition.class
|
|
12
|
+
|
|
13
|
+
(module
|
|
14
|
+
name: (identifier) @name) @definition.module
|
|
15
|
+
|
|
16
|
+
(interface_declaration
|
|
17
|
+
name: (type_identifier) @name) @definition.interface
|
|
18
|
+
|
|
19
|
+
(type_annotation
|
|
20
|
+
(type_identifier) @name) @reference.type
|
|
21
|
+
|
|
22
|
+
(new_expression
|
|
23
|
+
constructor: (identifier) @name) @reference.class
|
package/tree-sitter-tsx.wasm
CHANGED
|
Binary file
|
|
Binary file
|
package/tree-sitter.json
CHANGED
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
],
|
|
15
15
|
"highlights": [
|
|
16
16
|
"queries/highlights.scm",
|
|
17
|
-
"
|
|
17
|
+
"javascript/queries/highlights.scm"
|
|
18
18
|
],
|
|
19
|
-
"injections": "
|
|
19
|
+
"injections": "javascript/queries/injections.scm",
|
|
20
20
|
"locals": [
|
|
21
21
|
"queries/locals.scm",
|
|
22
|
-
"
|
|
22
|
+
"javascript/queries/locals.scm"
|
|
23
23
|
],
|
|
24
24
|
"tags": [
|
|
25
25
|
"queries/tags.scm",
|
|
26
|
-
"
|
|
26
|
+
"javascript/queries/tags.scm"
|
|
27
27
|
],
|
|
28
28
|
"injection-regex": "^(ts|typescript)$"
|
|
29
29
|
},
|
|
@@ -40,14 +40,17 @@
|
|
|
40
40
|
],
|
|
41
41
|
"highlights": [
|
|
42
42
|
"queries/highlights.scm",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
43
|
+
"javascript/queries/highlights-jsx.scm",
|
|
44
|
+
"javascript/queries/highlights.scm"
|
|
45
|
+
],
|
|
46
|
+
"injections": "javascript/queries/injections.scm",
|
|
47
|
+
"locals": [
|
|
48
|
+
"queries/locals.scm",
|
|
49
|
+
"javascript/queries/locals.scm"
|
|
45
50
|
],
|
|
46
|
-
"injections": "node_modules/@willbooster/tree-sitter-javascript/queries/injections.scm",
|
|
47
|
-
"locals": "node_modules/@willbooster/tree-sitter-javascript/queries/locals.scm",
|
|
48
51
|
"tags": [
|
|
49
52
|
"queries/tags.scm",
|
|
50
|
-
"
|
|
53
|
+
"javascript/queries/tags.scm"
|
|
51
54
|
],
|
|
52
55
|
"injection-regex": "^(ts|typescript)$"
|
|
53
56
|
},
|
|
@@ -64,20 +67,23 @@
|
|
|
64
67
|
],
|
|
65
68
|
"highlights": [
|
|
66
69
|
"queries/highlights.scm",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
70
|
+
"javascript/queries/highlights-jsx.scm",
|
|
71
|
+
"javascript/queries/highlights.scm"
|
|
72
|
+
],
|
|
73
|
+
"injections": "javascript/queries/injections.scm",
|
|
74
|
+
"locals": [
|
|
75
|
+
"queries/locals.scm",
|
|
76
|
+
"javascript/queries/locals.scm"
|
|
69
77
|
],
|
|
70
|
-
"injections": "node_modules/@willbooster/tree-sitter-javascript/queries/injections.scm",
|
|
71
|
-
"locals": "node_modules/@willbooster/tree-sitter-javascript/queries/locals.scm",
|
|
72
78
|
"tags": [
|
|
73
79
|
"queries/tags.scm",
|
|
74
|
-
"
|
|
80
|
+
"javascript/queries/tags.scm"
|
|
75
81
|
],
|
|
76
82
|
"content-regex": "@flow"
|
|
77
83
|
}
|
|
78
84
|
],
|
|
79
85
|
"metadata": {
|
|
80
|
-
"version": "1.2.
|
|
86
|
+
"version": "1.2.7",
|
|
81
87
|
"license": "MIT",
|
|
82
88
|
"description": "TypeScript and TSX grammars for tree-sitter",
|
|
83
89
|
"authors": [
|
package/tsx/src/node-types.json
CHANGED
|
@@ -221,6 +221,10 @@
|
|
|
221
221
|
"type": "meta_property",
|
|
222
222
|
"named": true
|
|
223
223
|
},
|
|
224
|
+
{
|
|
225
|
+
"type": "new_expression",
|
|
226
|
+
"named": true
|
|
227
|
+
},
|
|
224
228
|
{
|
|
225
229
|
"type": "non_null_expression",
|
|
226
230
|
"named": true
|
|
@@ -3110,10 +3114,6 @@
|
|
|
3110
3114
|
"multiple": false,
|
|
3111
3115
|
"required": false,
|
|
3112
3116
|
"types": [
|
|
3113
|
-
{
|
|
3114
|
-
"type": "new_expression",
|
|
3115
|
-
"named": true
|
|
3116
|
-
},
|
|
3117
3117
|
{
|
|
3118
3118
|
"type": "primary_expression",
|
|
3119
3119
|
"named": true
|
|
@@ -4057,7 +4057,7 @@
|
|
|
4057
4057
|
"required": true,
|
|
4058
4058
|
"types": [
|
|
4059
4059
|
{
|
|
4060
|
-
"type": "
|
|
4060
|
+
"type": "primary_expression",
|
|
4061
4061
|
"named": true
|
|
4062
4062
|
}
|
|
4063
4063
|
]
|
|
@@ -217,6 +217,10 @@
|
|
|
217
217
|
"type": "meta_property",
|
|
218
218
|
"named": true
|
|
219
219
|
},
|
|
220
|
+
{
|
|
221
|
+
"type": "new_expression",
|
|
222
|
+
"named": true
|
|
223
|
+
},
|
|
220
224
|
{
|
|
221
225
|
"type": "non_null_expression",
|
|
222
226
|
"named": true
|
|
@@ -3106,10 +3110,6 @@
|
|
|
3106
3110
|
"multiple": false,
|
|
3107
3111
|
"required": false,
|
|
3108
3112
|
"types": [
|
|
3109
|
-
{
|
|
3110
|
-
"type": "new_expression",
|
|
3111
|
-
"named": true
|
|
3112
|
-
},
|
|
3113
3113
|
{
|
|
3114
3114
|
"type": "primary_expression",
|
|
3115
3115
|
"named": true
|
|
@@ -3808,7 +3808,7 @@
|
|
|
3808
3808
|
"required": true,
|
|
3809
3809
|
"types": [
|
|
3810
3810
|
{
|
|
3811
|
-
"type": "
|
|
3811
|
+
"type": "primary_expression",
|
|
3812
3812
|
"named": true
|
|
3813
3813
|
}
|
|
3814
3814
|
]
|