ts-morph
28.0.0 · 12 Apr 2026MIT46.3M / weekRepositoryHomepagenpmAtom feed
6.0.3 is the newest release of 6.x.
In short
13 breaking20 new1 faster3 fixed2 internal
- Breaking
JSDoc#setComment(...)and#getComment(...)are nowsetDescription(...)andgetDescription(). They also work according to #764. - Breaking
StructureTypeGuardsis nowStructure. - Breaking
PropertyDeclarationDeclaration and PropertyDeclarationStructure now can have a
declarekeyword (new in TS 3.7). - Breaking
JS docs will be written as a single line unless multi-line or starting with a newline. Additionally, getting a JS doc structure will have a newline at the start if the JS doc description is one line, but the JS doc is multi-line.
- Breaking
ProjectOptions#useVirtualFileSystemis nowuseInMemoryFileSystem. This is a more accurate name. - Breaking
Creating a Project with
useInMemoryFileSystem: truewill now load in the lib files into thenode_modules/typescript/libfolder. - Breaking
Due to the fix for #702, when using
Project#addSourceFileAtPathsdirectories that do not have an ancestor directory with a source file included in the results will no longer be added to the project. If you want to ensure that a directory and all its subfolders are added, useProject#addDirectoryAtPath(path, { recursive: true }). - Breaking
FileSystemHost#globis now asynchronous and#globSyncwas added.
Release note
The section about ts-morph of a note shared by several packages.
Bug Fixes
common: Fix running in the browser.
Fix bug where
Project#getRootDirectories()might return a directory not in the project.Getting symbol exports by name should call
ts.escapeLeadingUnderscoreson the name.
Features
Prefer writing single line JS docs. Add JSDoc#isMultiLine().
bootstrap: Rename addSourceFiles -> addSourceFilesByPaths to match ts-morph.
Manipulation error now throws a custom error object.
Directory#getSourceFilesnow accepts globs.Creating an in-memory file system now loads the lib files by default.
The virtual file system host will have lib files loaded by default.
Move TypeGuards to be static members of Node (methods still exist on TypeGuards, but will be removed later). (9b1e659), closes #728
Add Directory#clear().
Add QuestionDotTokenableNode.
SourceFile#applyTextChangesnow accepts objects of typets.TextChange.Add
getTypeExpressionOrThrow()toJSDocReturnTagandJSDocPropertyLikeTagAdd
JSDoc#insertTagsand similar methods.Add
JSDocTag#remove().Add
JSDocTag#setTagNameAdd JSDocTagStructure.
Expose
InMemoryFileSystemHost.Rename
useVirtualFileSystemtouseInMemoryFileSystemSupport declare keyword on class properties.
Upgrade to code-block-writer 10.1.0.
Wrap
BigIntLiteral.
performance
Fix Project#addSourceFileAtPaths being needlessly slow in some scenarios.
Breaking changes
- Breaking
JSDoc#setComment(...)and#getComment(...)are nowsetDescription(...)andgetDescription(). They also work according to #764. - Breaking
StructureTypeGuardsis nowStructure. - Breaking
PropertyDeclarationDeclaration and PropertyDeclarationStructure now can have a
declarekeyword (new in TS 3.7). - Breaking
JS docs will be written as a single line unless multi-line or starting with a newline. Additionally, getting a JS doc structure will have a newline at the start if the JS doc description is one line, but the JS doc is multi-line.
- Breaking
ProjectOptions#useVirtualFileSystemis nowuseInMemoryFileSystem. This is a more accurate name. - Breaking
Creating a Project with
useInMemoryFileSystem: truewill now load in the lib files into thenode_modules/typescript/libfolder. - Breaking
Due to the fix for #702, when using
Project#addSourceFileAtPathsdirectories that do not have an ancestor directory with a source file included in the results will no longer be added to the project. If you want to ensure that a directory and all its subfolders are added, useProject#addDirectoryAtPath(path, { recursive: true }). - Breaking
FileSystemHost#globis now asynchronous and#globSyncwas added. - Breaking
Renamed
Directory/Project#addExistingSourceFile->addSourceFileAtPath - Breaking
Renamed
Directory/Project#addExistingSourceFileIfExists->addSourceFileAtPathIfExists - Breaking
Renamed
Directory/Project#addExistingSourceFiles->addSourceFilesAtPaths - Breaking
Renamed
Directory/Project#addExistingDirectory->addDirectoryAtPath - Breaking
Renamed
Directory/Project#addExistingDirectoryIfExists->addDirectoryAtPathIfExists
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.