@willbooster/tree-sitter-typescript 1.2.8 → 1.2.9
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 +1 -1
- package/common/defineGrammar.js +8 -25
- package/package.json +3 -3
- package/tree-sitter-tsx.wasm +0 -0
- package/tree-sitter-typescript.wasm +0 -0
- package/tree-sitter.json +1 -1
- package/tsx/src/node-types.json +0 -4
- package/typescript/src/node-types.json +0 -4
package/README.md
CHANGED
|
@@ -105,7 +105,7 @@ cargo test
|
|
|
105
105
|
`script/tree-sitter` (also `bun run tree-sitter`) runs the tree-sitter CLI of WillBooster/tree-sitter at the runtime
|
|
106
106
|
version locked in `Cargo.lock`, so the parsers are generated, built, tested, and fuzzed with the generator and the
|
|
107
107
|
runtime this package ships. The first run downloads that CLI from its GitHub Release into `.tmp/`, or builds it with
|
|
108
|
-
`cargo` (
|
|
108
|
+
`cargo` (with the `cmake` that `mise.toml` pins) when the download fails or the release has no binary that runs here.
|
|
109
109
|
|
|
110
110
|
`bun run test/ci-setup` installs Chromium for the browser tests. `bun run build/ci` regenerates `typescript/src/` and
|
|
111
111
|
`tsx/src/` and builds both Wasm files. `bun run test` runs:
|
package/common/defineGrammar.js
CHANGED
|
@@ -248,13 +248,7 @@ module.exports = function defineGrammar(dialect) {
|
|
|
248
248
|
)
|
|
249
249
|
)
|
|
250
250
|
),
|
|
251
|
-
prec(
|
|
252
|
-
'template_call',
|
|
253
|
-
seq(
|
|
254
|
-
field('function', choice($.primary_expression, alias($._argumentless_new_expression, $.new_expression))),
|
|
255
|
-
field('arguments', $.template_string)
|
|
256
|
-
)
|
|
257
|
-
),
|
|
251
|
+
prec('template_call', seq(field('function', $.primary_expression), field('arguments', $.template_string))),
|
|
258
252
|
prec(
|
|
259
253
|
'member',
|
|
260
254
|
seq(
|
|
@@ -266,15 +260,14 @@ module.exports = function defineGrammar(dialect) {
|
|
|
266
260
|
)
|
|
267
261
|
),
|
|
268
262
|
|
|
269
|
-
//
|
|
270
|
-
//
|
|
271
|
-
// constructs `new A().b`, and `new new A()(2)` constructs `new A()`.
|
|
263
|
+
// tree-sitter-javascript's two forms of `new`, with type arguments; its 'member' and 'new' precedences group nested
|
|
264
|
+
// `new` as ECMAScript does (`new new A().b` constructs `new A().b`), and both forms are primary expressions.
|
|
272
265
|
new_expression: ($) =>
|
|
273
266
|
prec(
|
|
274
267
|
'new',
|
|
275
268
|
seq(
|
|
276
269
|
'new',
|
|
277
|
-
field('constructor', $.
|
|
270
|
+
field('constructor', $.primary_expression),
|
|
278
271
|
field('type_arguments', optional($.type_arguments)),
|
|
279
272
|
field('arguments', $.arguments)
|
|
280
273
|
)
|
|
@@ -283,12 +276,9 @@ module.exports = function defineGrammar(dialect) {
|
|
|
283
276
|
_argumentless_new_expression: ($) =>
|
|
284
277
|
prec.right(
|
|
285
278
|
'new',
|
|
286
|
-
seq('new', field('constructor', $.
|
|
279
|
+
seq('new', field('constructor', $.primary_expression), field('type_arguments', optional($.type_arguments)))
|
|
287
280
|
),
|
|
288
281
|
|
|
289
|
-
_new_constructor: ($) =>
|
|
290
|
-
prec('new', choice($.primary_expression, alias($._argumentless_new_expression, $.new_expression))),
|
|
291
|
-
|
|
292
282
|
assignment_expression: ($) =>
|
|
293
283
|
prec.right(
|
|
294
284
|
'assign',
|
|
@@ -299,20 +289,13 @@ module.exports = function defineGrammar(dialect) {
|
|
|
299
289
|
|
|
300
290
|
_lhs_expression: ($, previous) => choice(previous, $.non_null_expression),
|
|
301
291
|
|
|
302
|
-
primary_expression: ($, previous) => choice(previous, $.non_null_expression
|
|
292
|
+
primary_expression: ($, previous) => choice(previous, $.non_null_expression),
|
|
303
293
|
|
|
304
294
|
// If the dialect is regular typescript, we exclude JSX expressions and
|
|
305
295
|
// include type assertions. If the dialect is TSX, we do the opposite.
|
|
306
296
|
expression: ($, previous) => {
|
|
307
|
-
const choices = [
|
|
308
|
-
|
|
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');
|
|
297
|
+
const choices = [$.as_expression, $.satisfies_expression, $.instantiation_expression, $.internal_module];
|
|
298
|
+
const members = previous.members;
|
|
316
299
|
|
|
317
300
|
if (dialect === 'typescript') {
|
|
318
301
|
choices.push($.type_assertion);
|
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.9",
|
|
4
4
|
"description": "TypeScript and TSX grammars for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"@vitest/browser-playwright": "5.0.1",
|
|
52
52
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
53
53
|
"@willbooster/oxlint-config": "1.4.8",
|
|
54
|
-
"@willbooster/tree-sitter-javascript": "1.0.
|
|
54
|
+
"@willbooster/tree-sitter-javascript": "1.0.20",
|
|
55
55
|
"@willbooster/wb": "22.13.1",
|
|
56
|
-
"@willbooster/web-tree-sitter": "1.0.
|
|
56
|
+
"@willbooster/web-tree-sitter": "1.0.17",
|
|
57
57
|
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
58
58
|
"lefthook": "2.1.14",
|
|
59
59
|
"oxfmt": "0.70.0",
|
package/tree-sitter-tsx.wasm
CHANGED
|
Binary file
|
|
Binary file
|
package/tree-sitter.json
CHANGED
package/tsx/src/node-types.json
CHANGED