ts-morph

Navigate and manipulate TypeScript code with a friendlier compiler API wrapper

Library
npm
v28.0.0
6,214 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
56 /100 Fair
Development Activity 40
Maintenance 24
Community 60
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
79 /100 Good
Architecture 85
Code Quality 82
Innovation 80
Learning Curve 70

ts-morph wraps the raw TypeScript Compiler API in an object-oriented, discoverable layer, exposing a Project object that loads source files and lets you navigate, query, and programmatically modify TypeScript/JavaScript ASTs without wrestling with the compiler’s low-level node factories directly. Common tasks — adding an import, renaming a symbol project-wide, extracting an interface, or rewriting call expressions — become a handful of chainable method calls instead of manual AST construction and printer plumbing.

Because it sits directly on top of the real TypeScript compiler, ts-morph gets full type-checking and language-service accuracy for free, which is why it’s a common backbone for codemods, custom linters, doc generators, and code-generation tooling in TypeScript projects.

What You Get

  • A Project API for loading TypeScript/JavaScript files from disk, tsconfig.json, or an in-memory virtual file system
  • Wrapped, chainable AST node classes (SourceFile, ClassDeclaration, InterfaceDeclaration, etc.) with discoverable getters and mutators
  • Project-wide symbol renaming and reference finding backed by the real TypeScript language service
  • Code generation helpers for adding/removing imports, classes, methods, and properties without manual AST/printer code
  • A ts-morph.d.ts-backed structure API for describing code declaratively via plain objects instead of imperative builder calls

Common Use Cases

  • Writing codemods that rewrite deprecated API usage across a large TypeScript codebase
  • Generating TypeScript declaration files, client SDKs, or boilerplate from schemas or other source-of-truth definitions
  • Building custom static-analysis tools or linters that need type-checked AST traversal
  • Automating large-scale refactors (renaming exports, extracting interfaces, restructuring modules) safely across many files

Under The Hood

Architecture - The packages/ts-morph package’s src/compiler directory wraps every relevant TypeScript compiler AST node in a corresponding ts-morph class that holds a reference to the underlying ts.Node and the owning Project’s ts.Program/language service, so navigation methods (getParent(), getChildren()) and mutation methods (.rename(), .remove()) can delegate to either the raw AST or the language service as needed; src/codeBlockWriter provides an indentation-aware string builder used internally (and exposed) for generating source text.

Tech Stack - Pure TypeScript, organized as a monorepo (packages/ts-morph, packages/bootstrap, packages/common, packages/scripts) built with Deno tooling (deno.json/deno.lock) alongside npm packaging, bundled via Rollup (rollup.config.mjs), with a code-generation step (scripts/generation) that produces much of the wrapper-class boilerplate directly from the TypeScript compiler’s own type definitions to stay in sync across TS versions.

Code Quality - Tests run under Mocha (.mocharc.yml) with dedicated typeCheckDocumentation.ts and typeCheckLibrary.ts scripts that verify both the README’s code samples and the library’s own types actually compile, catching documentation drift that plain unit tests would miss; the breaking-changes.md file tracks API changes explicitly release over release, a sign of deliberate API stewardship for a library with a large public surface.

API Design - The chainable, getter-heavy API (sourceFile.getClasses()[0].getMethods()) mirrors how developers already think about ASTs, and the additional “structure” API (describing nodes as plain object literals) offers a declarative alternative to imperative builder calls for generation-heavy use cases, trading some API surface size for genuinely improved discoverability over the raw compiler API.

Used by 28 apps in this directory

TypeScript
95%
Apache 2.0

AionUi

AI Agents · Productivity

33,741

Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.

View details
88
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 95%
Updated yesterday
Python
87%
Apache 2.0

Apache Airflow

Data Engineering

47,268

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
64
Dependency
Built with
Python 87%
Updated today
TypeScript
96%
Other

Amplication

AI Code Assistants · Automation · Developer Tools

16,009

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
57
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 96%
Updated 3 months ago
Java
70%
Other

ByteChef

AI Agents · Automation

1,045

Unified open-source platform for AI agent orchestration and workflow automation with 180+ connectors, MCP support, and durable execution.

View details
86
Repo Health
82
Technical
66
Dependency
Built with
Java 70%
TypeScript 29%
Updated yesterday
Rust
54%
Other

Cameleer

AI Agents

23

A local-first desktop workspace for managing AI agents in an enterprise-style workflow — agent directory, Kanban task tracking, workspace chat, and a full runtime/audit log of agent actions and tool approvals.

View details
18
Repo Health
65
Technical
76
Dependency
Built with
Rust 54%
JavaScript 24%
TypeScript 15%
Updated 3 months ago
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

52,928

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
89
Repo Health
84
Technical
70
Dependency
Built with
TypeScript 99%
Updated today
TypeScript
98%
Apache 2.0

Cline

AI Code Assistants

70,793

An open-source AI coding agent that lives in your editor and terminal — reads and edits your codebase, runs commands, browses the web, and requires human approval for every action by default.

View details
91
Repo Health
74
Technical
65
Dependency
Built with
TypeScript 98%
Updated today
TypeScript
45%
Other

Convex Backend

Databases · Developer Tools

12,754

Open-source reactive database that lets developers build live-updating apps with pure TypeScript, strong consistency, and real-time subscriptions—no separate API layer required.

View details
88
Repo Health
82
Technical
65
Dependency
Built with
TypeScript 45%
Rust 43%
Updated today
TypeScript
74%
Apache 2.0

Fern

Developer Tools

3,822

Fern turns a single OpenAPI, AsyncAPI, or Protobuf definition into type-safe SDKs for nine languages and a hosted API documentation site, all from one CLI and one source of truth.

View details
90
Repo Health
86
Technical
66
Dependency
Built with
TypeScript 74%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers