ts-morph
28.0.0 · 12 Apr 2026MIT46.3M / weekRepositoryHomepagenpmAtom feed
2.3.0 is the newest release of 2.x.
In short
19 breaking22 new8 fixed1 changed6 internal
- Breaking
FileSystemHost.isCaseSensitive() is now required in implementations.
- Breaking
The default export was removed. Use the named
Projectexport from now on. - Breaking
ModuledNode#getExportedDeclarations() now returns a map with a key as the export name and the value as an array of declarations that are exported.
- Breaking
Removed
.bodyText,.classes,.enumsproperties on structures. Replaced with.statementsproperty. - Breaking
Comments are parsed as children in certain scenarios. See #575 for more details.
- Breaking
Type#getArrayType()is nowType#getArrayElementType(). This was renamed to better reflect what the method does. - Breaking
EnumMember#getStructure()no longer returns the#valueand will only return#initializer.#valueshould be seen as more of a convenience property for setting the initializer. - Breaking
Symbol#getXByName-like methods were renamed toSymbol#getX.
Release note
The section about ts-morph of a note shared by several packages.
Bug Fixes
The code writer did not handle escaping string chars in strings.
Node#getDescendantStatements()is now properly typed as possibly returning anExpression.ReturnTypedNodeandTypedNode's#getStructure()should return the type and return type text without leading indentation.DefinitionInfo.getDeclarationNode() should return a source file when the kind is "module" and width equal to the source file.
Do not add trailing whitespace when a jsdoc's description includes a blank line.
Fix removing class elements on object literal expressions.
Getting/inserting statements on a ModuleBlock was throwing an error.
isOverload()should returntruefor abstract methods.
Features
Node - Ability to get text without leading indentation.
Add Node#forEachChildAsArray()
ParameterDeclaration now implements BindingNamedNode instead of DeclarationNamedNode.
ModuledNode#getExportedDeclarations() now returns a map.
Extended comments
TraversalControl - Add ability to return a value.
SourceFile#getLineAndColumnAtPos
Move
ChildOrderableNodetoStatement.Add SourceFile#fixUnusedIdentifiers (e4b1b64) - @cancerberoSgx
Add
CombinedCodeAction#applyChanges()Add
RefactorEditInfo#applyChanges()(ca0ca8c) - @cancerberoSgxMake
emitasync and add newemitSyncSymbol#getXByName-like methods are nowSymbol#getX.#addStatements/#insertStatementsnow also accepts an array of strings or writer functions.Ability to add/insert statement structures.
Add
Type#getArrayElementTypeOrThrow()Add ClassMemberStructures, InterfaceMemberStructures, and Structures type aliases.
Add ObjectLiteralElement.
getName() should always just return the name node text.
Removed
Project#applyFileTextChanges(). AddedFileTextChanges#applyChanges().Replace
StatementedNodewith new.statementsproperty / Add trivia properties to structuresWrap ClassElement.
reactor
Target ES2015.
Breaking changes
- Breaking
The default export was removed. Use the named
Projectexport from now on. - Breaking
ModuledNode#getExportedDeclarations() now returns a map with a key as the export name and the value as an array of declarations that are exported.
- Breaking
Removed
BodyableNodeStructure,BodiedNodeStructure,ModuledNodeStructure.
- Breaking
Removed
.bodyText,.classes,.enumsproperties on structures. Replaced with.statementsproperty. - Breaking
Comments are parsed as children in certain scenarios. See #575 for more details.
- Breaking
Type#getArrayType()is nowType#getArrayElementType(). This was renamed to better reflect what the method does. - Breaking
ParameterDeclaration now implements BindingNamedNode instead of DeclarationNamedNode.
- Breaking
EnumMember#getStructure()no longer returns the#valueand will only return#initializer.#valueshould be seen as more of a convenience property for setting the initializer. - Breaking
Symbol#getXByName-like methods were renamed toSymbol#getX. - Breaking
Project#applyFileTextChanges()has moved toFileTextChanges#applyChanges(). - Breaking
SourceFile#getLineNumberAtPosis nowSourceFile#getLineAndColumnAtPos - Breaking
JsxText#containsOnlyWhiteSpaces() is now #containsOnlyTriviaWhiteSpaces().
FileSystemHostrequiresrealpathSync. - Breaking
Removed
VariableDeclarationListStructureandVariableDeclarationList#setand#getStructure. This was done to simplify the structures. - Breaking
The library now targets ES2015.
- Breaking
JsxAttributeStructureandJsxSpreadAttributeStructureare now differentiated based on their.kindproperty. - Breaking
JsxElementStructureandJsxSelfClosingElementStructureare now differentiated based on their.kindproperty. - Breaking
FileSystemHost.isCaseSensitive() is now required in implementations.
- Breaking
Removed DeclarationNamedNode.
- Breaking
InitializerSetExpressionableNode was removed and merged with InitializerExpressionableNode.
- Breaking
InitializerGetExpressionableNode was renamed to InitializerExpressionGetableNode.
- Breaking
getName() always returns the name node text and now never throws.
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.