Skip to content

grammar(ts): build TypeScript from marionebl's maintained fork - #15

Merged
inth3shadows merged 4 commits into
mainfrom
grammar/marionebl-base
Nov 6, 2026
Merged

inth3shadows merged 4 commits into
mainfrom
grammar/marionebl-base

Conversation

@inth3shadows

Copy link
Copy Markdown
Owner

What

Switches the vendored tree-sitter-typescript base from upstream v0.23.2 to
marionebl/tree-sitter-typescript@53071c9.
docs/grammars/tree-sitter-typescript.patch is now our delta on that base:

  • dokimasia 55b0687: an import type is a primary type (import("m").X[], keyof import("m").X).
  • dokimasia 96ce7e6: f<typeof import("m")>() parses as a call.
  • ours: out as a type-parameter name (<out>, <in out>), plus const after the variance (<in const T>).
    <in out> vs <in out T> needs a [variance] conflict.

Regenerated with tree-sitter-cli 0.25.10 (ABI 15) into the wasm and the kernel's vendored C.

Differential (tsc-ok, tree-sitter-error files)

corpus before marionebl only this PR
effect 185 29 29
zod 0 0 0
excalidraw 5 5 0
vscode 11 11 3
total 201 45 32

new 0, worse 0 at each step. marionebl alone fails only variance-out-name.*. The baseline is updated, and a re-run after --update exits 0.

Tests

  • npm run build:kernel exit 0. Variance, kernel-*, and extraction tests: Test Files 20 passed (20), Tests 1086 passed | 2 skipped.
  • Full npx vitest run: 6 failures before the helper fix. 4 were typescript-variance-parse (in/out now sit in a variance node; helper updated, cases unchanged). index-recovery-off-thread passes on rerun. The ui-server-api "busiest symbol" test fails with expected 33 to be greater than 300 on unmodified main bb0ea5b as well, because it reads the local .codegraph index.
  • The new strict fixtures overload-asi, template-literal-escapes, export-type-star and import-type-primary are all agree-ok.

No EXTRACTION_VERSION bump: the fork re-indexes JS/TS repos manually after deploying, which follows the #13 precedent.

Switch the vendored tree-sitter-typescript base from upstream v0.23.2
(no commit since 2025-01-30) to marionebl/tree-sitter-typescript@53071c9.
On top of it, the patch now carries dokimasia 55b0687 + 96ce7e6 (import
types as primary types, typeof import() in call type arguments) and our
own `out`-as-a-name alias and `<in const T>`.

Regenerated with tree-sitter-cli 0.25.10 (ABI 15) into both the wasm and
the kernel's vendored C. The differential job: divergent files across
Effect / Zod / Excalidraw / VS Code drop 201 -> 32, new 0, worse 0.
Fixes the colbymchenry#335 overload-after-member ASI case.

The variance test reads `in` / `out` from the new `variance` node.
Four strict ts-syntax fixtures pin what the base and dokimasia fix.
marionebl's colbymchenry#335 fix inserts an implicit `;` before any `<` that starts a
line in a type or class body. Right after a bare member name tsc reads
`find\n  <T>(id): T` as one method, but the scanner split it into a
property plus a call signature (no parse error in an interface), and a
class method lost its call edges. The grammar now lists `(` as an
external the scanner never produces, as JavaScript does for '||', and
the scanner skips that `;` when `(` is valid, which is only right after a
member name. colbymchenry#335's shapes (`a: string\n<A>(self: A): A`) still split.

Comparing every node of every file over the four corpora, src and ui/src,
the fix changes no tree (0 of 14,929); differential unchanged at 32.

Also: node-kind test for both sides, tsx twins for the new strict
fixtures, Known limits for parenthesized import types and the scanner's
`in` edge cases, and doc provenance fixes.
The previous fix skipped ASI before a line-start `<` whenever `(` could
come next. `(` is also valid after `typeof x` / `import("m").X` types and
after `return`, so `a: typeof b\n<A>(self: A): A` errored again and
`return\n<any>x` kept the expression.

The grammar now has a never-produced external, `_member_signature_marker`,
between the name and the signature of method_signature, method_definition
and abstract_method_signature, so it is valid exactly where tsc reads a
next-line `<` or `(` as that member's signature. That also keeps
`find\n(id): T` one method, which was split even before the base switch.

Against the build without the scanner hunk, no tree changes on 15,037
files (corpora, src, ui/src, TypeScript's lib) except the member fixtures;
differential unchanged at 32.
Round-3 review: the return-after-ASI test gets a tsx twin, and the
Moving-the-base checklist names the define-grammar.js half of the member
marker alongside the scanner.h hunk.
@inth3shadows
inth3shadows merged commit 1dcdbbe into main Nov 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant