tree-sitter-typescript
TypeScript and TSX grammars for the tree-sitter incremental parsing framework.
Repository Health
Technical Analysis
tree-sitter-typescript provides two tree-sitter grammars — one for TypeScript and one for TSX — that let editors, linters, and static-analysis tools build and incrementally update a concrete syntax tree for TypeScript source files. Because TSX is a genuinely distinct dialect (JSX syntax mixed with TypeScript types), the package ships it as a separate grammar rather than trying to overload a single parser for both.
The grammar is distributed as native bindings for Rust, Node.js, Python, Go, Swift, and C/CMake consumers, so the same underlying parser (generated from grammar.js and compiled C parser tables) can be embedded in editors like Neovim and Helix, in language-server tooling, or in any application that needs a fast, error-tolerant TypeScript parse tree rather than a full type-checking compiler.
What You Get
- Two separate grammars —
typescriptandtsx— reflecting that TSX is a distinct dialect from plain TypeScript - Native bindings for Rust, Node.js, Python, Go, Swift, and C/CMake so the parser can be embedded in editors and tooling written in any of those languages
- Query files under
queries/for syntax highlighting and other tree-sitter-consuming features - Incremental, error-tolerant parsing suitable for live-editing scenarios rather than a batch compiler pass
- A CI-tested grammar kept in sync with the upstream tree-sitter grammar DSL and parser generator
Common Use Cases
- Powering TypeScript/TSX syntax highlighting in editors such as Neovim, Helix, and other tree-sitter-based editors
- Building structural code search, refactoring tools, or linters that need a real syntax tree rather than regex-based matching
- Embedding a TypeScript parser in a Rust, Python, or Node.js application via the language-specific bindings
- Implementing custom static-analysis or code-intelligence tooling that needs incremental re-parsing as a file is edited
Under The Hood
Architecture - The grammars are defined in typescript/grammar.js and tsx/grammar.js using tree-sitter’s grammar DSL, then compiled by the tree-sitter CLI into C parser tables checked into typescript/src and tsx/src. Per-language bindings live under bindings/ (c, rust, node, python, go, swift), each a thin wrapper that loads the compiled parser and exposes it through that language’s native API; queries/ holds tree-sitter query files consumed by editors for highlighting and other features.
Tech Stack - The grammar definitions are JavaScript, but the generated parsers are C (22.7% of the repo), with Rust bindings built via a build.rs script declared in Cargo.toml, Node bindings via binding.gyp, and equivalent packaging for Python (setup.py/pyproject.toml), Go (go.mod), and Swift (Package.swift) — a genuinely polyglot distribution model built around one shared C parser core.
Code Quality - CI (GitHub Actions) runs the grammar’s test corpus on every change; the project has a low but steady maintenance cadence (739 total commits since 2017, most recent release in November 2024) reflecting that TypeScript/TSX grammar changes are infrequent once a language’s syntax stabilizes, though this also means newer TypeScript syntax may lag behind the latest release.
API Design - Consumers require two distinct exports — require('tree-sitter-typescript').typescript and .tsx — which is a deliberate, low-boilerplate way of surfacing that TSX is not simply ‘TypeScript inside a JSX file.’ Each language binding follows that host language’s idiomatic parser API (e.g. tree_sitter::Language in Rust), so developers already familiar with tree-sitter in one language transfer that knowledge easily to another.
Used by 4 apps in this directory
cocoindex
Data Engineering · AI Development
An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.
codegraph
Developer Tools · AI Code Assistants
A pre-indexed code knowledge graph that cuts AI tool calls by 58% and token costs by 16% — auto-syncing, 100% local, works with Claude Code, Cursor, Codex, and more.
Tabby
AI Code Assistants
Self-hosted AI coding assistant — run GitHub Copilot-grade code completion on your own hardware with no cloud dependency.
Windmill
Automation · Developer Tools
Turn scripts into webhooks, workflows, and auto-generated UIs — the fastest self-hostable workflow engine, 13x faster than Airflow.