A maintained fork of tree-sitter/tree-sitter-typescript,
which has had no commits since v0.23.2 (January 2025). Every grammar change here is checked
against tsc.
I maintain a fork of codegraph (mine), which builds a code graph from tree-sitter parses. When a TypeScript file fails to parse, its symbols and calls silently drop out of the index. Tracking those losses down meant checking the grammar against the compiler, and the fixes ended up here.
- tsc differential (docs/differential.md):
tsc's syntax diagnostics are the ground truth, and every.ts/.tsxfile in pinned corpora (Effect, Zod, Excalidraw and VS Codesrc/, about 14.5k files; a second set adds Angular, NestJS, Vue and TanStack Query, about 9.6k more) plus one-construct fixtures intest/tsc-fixtures/is parsed with both grammars. A file that tsc accepts and the grammar rejects fails CI unless it is already in the baseline. On the first set, upstream v0.23.2 fails 259 files; this fork fails none. On the second, the fork fails 2 files, each an open issue (#62, #133). - Tree accuracy (docs/accuracy.md): the first set of corpora, node by node.
Each expression and type node is compared with the node tsc builds (kind and exact span). From
upstream v0.23.2 to this fork's main, wrong nodes fell from 17,344 to 0 and missed nodes from
13,071 to 0, out of 6.2 million. Measured on 2026-11-18 against upstream
masterand the 15 other forks that change the grammar, this fork had the fewest wrong and missed nodes. The next best had 6,392 and 5,822. The second set has 6 wrong and 2 missed nodes, all in the file of #62 (docs/accuracy.md). TypeScript's own test suite is an edge-case corpus for the same check (docs/accuracy.md). - Corpus tests (
test/corpus/) pin node shapes, and node tests inbindings/node/pin field readings for the trickier cases.
- Based on marionebl's fork (
53071c9, which includes upstream v0.23.2), with commits from dokimasia's fork (authorship kept). MIT, as upstream. - Generated with tree-sitter-cli 0.25.10 (ABI 15).
- Node types: every change to
node-types.jsonis listed in the CHANGELOG, because editor queries match on node names. Most fixes change no node types. - Published as
tree-sitter-typescript-nexton npm and crates.io (see Usage). No PyPI release yet; if you need one, open an issue. - Issues and PRs are welcome. A reproduction that
tscaccepts is the most useful bug report.
TypeScript and TSX grammars for tree-sitter.
Because TSX and TypeScript are actually two different dialects, this module defines two grammars. Require them as follows:
require("tree-sitter-typescript").typescript; // TypeScript grammar
require("tree-sitter-typescript").tsx; // TSX grammarFor Javascript files with flow type annotations you can use the tsx parser.
On npm the package is named tree-sitter-typescript-next. Installed under upstream's name with
an alias, it replaces tree-sitter-typescript without code changes:
npm install tree-sitter-typescript@npm:tree-sitter-typescript-nextIn Rust, the crate is named tree-sitter-typescript-next, but its library keeps upstream's
name, so it replaces tree-sitter-typescript without code changes:
[dependencies]
tree-sitter-typescript = { package = "tree-sitter-typescript-next", version = "0.25" }let language = tree_sitter_typescript::LANGUAGE_TYPESCRIPT; // or LANGUAGE_TSXReferences