README 未说明具体依赖版本要求;@ts-morph/bootstrap 是独立包,需单独安装
ts-morph
dsherretMIT活跃维护把 TypeScript 编译器 API 封装成更好用的接口,方便做静态分析和用代码批量修改 TypeScript 源码。
TypeScript Compiler API wrapper for static analysis and programmatic code changes.
TypeScript Compiler API 的封装库,让程序化导航和修改 TS/JS 代码更简单
把 TypeScript 编译器 API 封装成更好用的接口,方便做静态分析和用代码批量修改 TypeScript 源码。
核心能力
- 封装 TypeScript Compiler API,简化 AST 操作
- 支持程序化导航 TypeScript 与 JavaScript 代码
- 支持以编程方式修改代码
- 提供 @ts-morph/bootstrap 快速接入 Compiler API
容易踩的坑
- 28.0.0最新正式版2026-04-12 · 2026-04-12 18:02 UTC
What's Changed
- feat(BREAKING): TypeScript 6.0 by @dsherret in https://github.com/dsherret/ts-morph/pull/1669
- feat: standalone
printStructurefunction by @dsherret in https://github.com/dsherret/ts-morph/pull/1670 - fix:
InvalidOperationErrorinaddTypeArgumentby @jfirebaugh in https://github.com/dsherret/ts-morph/pull/1663
Note there are some breaking changes due to TypeScript 6.0. Read more here: https://devblogs.microsoft.com/typescript/announcing-typescript-6-0/
As part of this release, structures can now be printed to a string using the
printStructurefunction.import { printStructure, StructureKind } from "ts-morph"; const code = printStructure({ kind: StructureKind.Class, name: "MyClass", isExported: true, properties: [{ name: "myProp", type: "string" }], methods: [{ name: "myMethod", parameters: [{ name: "param", type: "number" }], returnType: "void", }], }); console.log(code);Outputs:
export class MyClass { myProp: string; myMethod(param: number): void { } }New Contributors
- @jfirebaugh made their first contribution in https://github.com/dsherret/ts-morph/pull/1663
Full Changelog: https://github.com/dsherret/ts-morph/compare/27.0.2...28.0.0
- 27.0.22025-10-12 · 2025-10-12 14:54 UTC
查看更新说明
What's Changed
- Fixes the npm publish in order to get the fixes in from 27.0.1
- fix: browser support no longer working since https://github.com/dsherret/ts-morph/pull/1628 in 26.0.0 due to missing browser fields by @BossSloth in https://github.com/dsherret/ts-morph/pull/1654
Full Changelog: https://github.com/dsherret/ts-morph/compare/27.0.1...27.0.2
- Fixes the npm publish in order to get the fixes in from 27.0.1
- 27.0.12025-09-17 · 2025-09-17 19:24 UTC
查看更新说明
What's Changed
- fix: browser support no longer working since #1628 in 26.0.0 due to missing browser fields by @BossSloth in https://github.com/dsherret/ts-morph/pull/1654
New Contributors
- @BossSloth made their first contribution in https://github.com/dsherret/ts-morph/pull/1654
Full Changelog: https://github.com/dsherret/ts-morph/compare/27.0.0...27.0.1
- 27.0.02025-09-07 · 2025-09-07 20:47 UTC
查看更新说明
What's Changed
- perf: switch to tinyglobby by @benmccann in https://github.com/dsherret/ts-morph/pull/1635
- fix: re-export StandardizedFilePath from @ts-morph/common by @kronodeus in https://github.com/dsherret/ts-morph/pull/1637
- chore: fix ci by @dsherret in https://github.com/dsherret/ts-morph/pull/1645
- feat:
TypeChecker- addgetAwaitedTypeby @JHawk0224 in https://github.com/dsherret/ts-morph/pull/1643 - feat: TypeScript 5.9 by @dsherret in https://github.com/dsherret/ts-morph/pull/1646
- feat: wrap OptionalTypeNode by @dsherret in https://github.com/dsherret/ts-morph/pull/1647
- feat: wrap
JSDocImportTagby @dsherret in https://github.com/dsherret/ts-morph/pull/1648 - fix: remove invalid sourceMappingURL from build output by @dsherret in https://github.com/dsherret/ts-morph/pull/1649
- feat: ability to add and remove the defer keyword in imports by @dsherret in https://github.com/dsherret/ts-morph/pull/1651
New Contributors
- @JHawk0224 made their first contribution in https://github.com/dsherret/ts-morph/pull/1643
Full Changelog: https://github.com/dsherret/ts-morph/compare/26.0.0...27.0.0
- 26.0.02025-05-19 · 2025-05-19 19:08 UTC
查看更新说明
What's Changed
- feat: TypeScript 5.8 https://github.com/dsherret/ts-morph/pull/1628
- fix: Improve comma appending logic to handle nested template literals correctly by @kingston in https://github.com/dsherret/ts-morph/pull/1630
- fix(bootstrap): ignore dist-deno folder for npm publish https://github.com/dsherret/ts-morph/pull/1610
- feat:
npm publishwith provenance https://github.com/dsherret/ts-morph/pull/1634
New Contributors
- @kingston made their first contribution in https://github.com/dsherret/ts-morph/pull/1630
Full Changelog: https://github.com/dsherret/ts-morph/compare/25.0.1...26.0.0
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Monorepo for ts-morph and related projects.
Packages
- ts-morph - TypeScript Compiler API wrapper. Provides an easier way to programmatically navigate and manipulate TypeScript and JavaScript code.
- @ts-morph/bootstrap - Separate library for getting quickly setup with the Compiler API.