@willbooster/tree-sitter-typescript 1.2.13 → 1.2.14
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 +6 -1
- package/common/defineGrammar.js +13 -1
- package/package.json +9 -6
- 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 +5 -1
- package/typescript/src/node-types.json +5 -1
package/README.md
CHANGED
|
@@ -108,7 +108,12 @@ runtime this package ships. The first run downloads that CLI from its GitHub Rel
|
|
|
108
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
|
-
`tsx/src/` and builds both Wasm files.
|
|
111
|
+
`tsx/src/` and builds both Wasm files. It also refreshes `common/typeScriptKeywords.h` from the pinned
|
|
112
|
+
`typescript-reference` API (TypeScript 5.9.3), which supplies the global-augmentation lookahead vocabulary.
|
|
113
|
+
The native TypeScript package remains the type checker. Run `bun run generate-keywords` after changing the reference;
|
|
114
|
+
verification checks the committed header with `bun run check-keywords`.
|
|
115
|
+
|
|
116
|
+
`bun run test` runs:
|
|
112
117
|
|
|
113
118
|
- the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK).
|
|
114
119
|
Cases run with the `typescript` grammar unless they carry `:language(tsx)`;
|
package/common/defineGrammar.js
CHANGED
|
@@ -4,6 +4,7 @@ const JavaScript = require('@willbooster/tree-sitter-javascript/grammar');
|
|
|
4
4
|
// Words that are keywords only in some positions and identifiers elsewhere, besides the JavaScript grammar's.
|
|
5
5
|
const TYPESCRIPT_CONTEXTUAL_KEYWORDS = [
|
|
6
6
|
'declare',
|
|
7
|
+
'global',
|
|
7
8
|
'namespace',
|
|
8
9
|
'type',
|
|
9
10
|
'public',
|
|
@@ -64,6 +65,8 @@ module.exports = function defineGrammar(dialect) {
|
|
|
64
65
|
$._type_arguments_end,
|
|
65
66
|
$._type_arguments_end_before_expression,
|
|
66
67
|
$._new_type_arguments_end,
|
|
68
|
+
$._global_declaration_start,
|
|
69
|
+
$._global_declaration_end,
|
|
67
70
|
$.__error_recovery,
|
|
68
71
|
],
|
|
69
72
|
|
|
@@ -473,6 +476,7 @@ module.exports = function defineGrammar(dialect) {
|
|
|
473
476
|
export_statement: ($, previous) =>
|
|
474
477
|
choice(
|
|
475
478
|
previous,
|
|
479
|
+
seq('export', field('declaration', alias($.global_declaration, $.internal_module))),
|
|
476
480
|
seq('export', 'type', $.export_clause, optional($._from_clause), $._semicolon),
|
|
477
481
|
seq('export', 'type', choice('*', $.namespace_export), $._from_clause, $._semicolon),
|
|
478
482
|
seq('export', '=', $.expression, $._semicolon),
|
|
@@ -649,6 +653,8 @@ module.exports = function defineGrammar(dialect) {
|
|
|
649
653
|
)
|
|
650
654
|
),
|
|
651
655
|
|
|
656
|
+
statement: ($, previous) => choice(previous, alias($.global_declaration, $.internal_module)),
|
|
657
|
+
|
|
652
658
|
declaration: ($, previous) =>
|
|
653
659
|
choice(
|
|
654
660
|
previous,
|
|
@@ -706,7 +712,7 @@ module.exports = function defineGrammar(dialect) {
|
|
|
706
712
|
'declare',
|
|
707
713
|
choice(
|
|
708
714
|
$.declaration,
|
|
709
|
-
seq('global', $.statement_block),
|
|
715
|
+
seq(alias($._global_declaration_start, 'global'), choice($.statement_block, $._global_declaration_end)),
|
|
710
716
|
seq('module', '.', alias($.identifier, $.property_identifier), ':', $.type, $._semicolon)
|
|
711
717
|
)
|
|
712
718
|
),
|
|
@@ -756,6 +762,12 @@ module.exports = function defineGrammar(dialect) {
|
|
|
756
762
|
|
|
757
763
|
internal_module: ($) => seq('namespace', $._module),
|
|
758
764
|
|
|
765
|
+
global_declaration: ($) =>
|
|
766
|
+
seq(
|
|
767
|
+
field('name', alias($._global_declaration_start, $.identifier)),
|
|
768
|
+
choice(field('body', $.statement_block), $._global_declaration_end)
|
|
769
|
+
),
|
|
770
|
+
|
|
759
771
|
_module: ($) =>
|
|
760
772
|
prec.right(
|
|
761
773
|
seq(
|
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.14",
|
|
4
4
|
"description": "TypeScript and TSX grammars for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -28,9 +28,11 @@
|
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build-wasm": "script/tree-sitter build --wasm typescript && script/tree-sitter build --wasm tsx",
|
|
31
|
-
"build/ci": "script/tree-sitter generate typescript/grammar.js && script/tree-sitter generate tsx/grammar.js && bun run build-wasm",
|
|
32
|
-
"
|
|
31
|
+
"build/ci": "bun run generate-keywords && script/tree-sitter generate typescript/grammar.js && script/tree-sitter generate tsx/grammar.js && bun run build-wasm",
|
|
32
|
+
"check-keywords": "bun scripts/generateGlobalKeywords.ts --check",
|
|
33
|
+
"cleanup": "bun run check-keywords && bun wb lint --fix --format",
|
|
33
34
|
"format": "bun wb lint --format",
|
|
35
|
+
"generate-keywords": "bun scripts/generateGlobalKeywords.ts",
|
|
34
36
|
"lint": "bun wb lint",
|
|
35
37
|
"lint-fix": "bun wb lint --fix",
|
|
36
38
|
"prepare": "(bun lefthook install || true) && (test ! -f .lefthook/normalize-bun-lockfile.sh || bash .lefthook/normalize-bun-lockfile.sh)",
|
|
@@ -48,7 +50,7 @@
|
|
|
48
50
|
"devDependencies": {
|
|
49
51
|
"@tsconfig/bun": "1.0.11",
|
|
50
52
|
"@types/bun": "1.4.2",
|
|
51
|
-
"@vitest/browser-playwright": "5.0.
|
|
53
|
+
"@vitest/browser-playwright": "5.0.2",
|
|
52
54
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
53
55
|
"@willbooster/oxlint-config": "1.4.8",
|
|
54
56
|
"@willbooster/tree-sitter-javascript": "1.0.21",
|
|
@@ -58,13 +60,14 @@
|
|
|
58
60
|
"lefthook": "2.1.14",
|
|
59
61
|
"oxfmt": "0.70.0",
|
|
60
62
|
"oxlint": "1.85.0",
|
|
61
|
-
"oxlint-tsgolint": "7.0.
|
|
63
|
+
"oxlint-tsgolint": "7.0.2003",
|
|
62
64
|
"playwright": "1.63.0",
|
|
63
65
|
"semantic-release": "25.0.9",
|
|
64
66
|
"sort-package-json": "4.0.0",
|
|
65
67
|
"typescript": "7.0.2",
|
|
68
|
+
"typescript-reference": "npm:typescript@5.9.3",
|
|
66
69
|
"vite": "8.3.0",
|
|
67
|
-
"vitest": "5.0.
|
|
70
|
+
"vitest": "5.0.2",
|
|
68
71
|
"wrangler": "4.135.0"
|
|
69
72
|
},
|
|
70
73
|
"peerDependencies": {
|
package/tree-sitter-tsx.wasm
CHANGED
|
Binary file
|
|
Binary file
|
package/tree-sitter.json
CHANGED
package/tsx/src/node-types.json
CHANGED
|
@@ -413,6 +413,10 @@
|
|
|
413
413
|
"type": "import_statement",
|
|
414
414
|
"named": true
|
|
415
415
|
},
|
|
416
|
+
{
|
|
417
|
+
"type": "internal_module",
|
|
418
|
+
"named": true
|
|
419
|
+
},
|
|
416
420
|
{
|
|
417
421
|
"type": "labeled_statement",
|
|
418
422
|
"named": true
|
|
@@ -647,7 +651,7 @@
|
|
|
647
651
|
"fields": {},
|
|
648
652
|
"children": {
|
|
649
653
|
"multiple": true,
|
|
650
|
-
"required":
|
|
654
|
+
"required": false,
|
|
651
655
|
"types": [
|
|
652
656
|
{
|
|
653
657
|
"type": "declaration",
|
|
@@ -409,6 +409,10 @@
|
|
|
409
409
|
"type": "import_statement",
|
|
410
410
|
"named": true
|
|
411
411
|
},
|
|
412
|
+
{
|
|
413
|
+
"type": "internal_module",
|
|
414
|
+
"named": true
|
|
415
|
+
},
|
|
412
416
|
{
|
|
413
417
|
"type": "labeled_statement",
|
|
414
418
|
"named": true
|
|
@@ -643,7 +647,7 @@
|
|
|
643
647
|
"fields": {},
|
|
644
648
|
"children": {
|
|
645
649
|
"multiple": true,
|
|
646
|
-
"required":
|
|
650
|
+
"required": false,
|
|
647
651
|
"types": [
|
|
648
652
|
{
|
|
649
653
|
"type": "declaration",
|