Skip to content

About

tree-sitter TypeScript/TSX grammar, checked against tsc on real-world code (fork of tree-sitter/tree-sitter-typescript via marionebl)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1,036 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tree-sitter-typescript (tsc-checked fork)

CI tsc differential

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.

Why this fork exists

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.

How it is checked

  • tsc differential (docs/differential.md): tsc's syntax diagnostics are the ground truth, and every .ts/.tsx file in pinned corpora (Effect, Zod, Excalidraw and VS Code src/, about 14.5k files; a second set adds Angular, NestJS, Vue and TanStack Query, about 9.6k more) plus one-construct fixtures in test/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 master and 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 in bindings/node/ pin field readings for the trickier cases.

Provenance and policy

  • 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.json is listed in the CHANGELOG, because editor queries match on node names. Most fixes change no node types.
  • Published as tree-sitter-typescript-next on 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 tsc accepts is the most useful bug report.

Usage

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 grammar

For 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-next

In 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_TSX

References

About

tree-sitter TypeScript/TSX grammar, checked against tsc on real-world code (fork of tree-sitter/tree-sitter-typescript via marionebl)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages