Packages

ts-morph

28.0.0 · 12 Apr 2026MIT46.3M / weekRepositoryHomepagenpmAtom feed

Your version

2.0.0

major11 Apr 2019Where it was published

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 Project export 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, .enums properties on structures. Replaced with .statements property.

  • Breaking

    Comments are parsed as children in certain scenarios. See #575 for more details.

  • Breaking

    Type#getArrayType() is now Type#getArrayElementType(). This was renamed to better reflect what the method does.

  • Breaking

    EnumMember#getStructure() no longer returns the #value and will only return #initializer. #value should be seen as more of a convenience property for setting the initializer.

  • Breaking

    Symbol#getXByName-like methods were renamed to Symbol#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 an Expression.

  • ReturnTypedNode and TypedNode'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 return true for 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 ChildOrderableNode to Statement.

  • Add SourceFile#fixUnusedIdentifiers (e4b1b64) - @cancerberoSgx

  • Add CombinedCodeAction#applyChanges()

  • Add RefactorEditInfo#applyChanges() (ca0ca8c) - @cancerberoSgx

  • Make emit async and add new emitSync

  • Symbol#getXByName-like methods are now Symbol#getX.

  • #addStatements/#insertStatements now 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(). Added FileTextChanges#applyChanges().

  • Replace StatementedNode with new .statements property / Add trivia properties to structures

  • Wrap ClassElement.

reactor

  • Target ES2015.

Breaking changes

  • Breaking

    The default export was removed. Use the named Project export 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, .enums properties on structures. Replaced with .statements property.

  • Breaking

    Comments are parsed as children in certain scenarios. See #575 for more details.

  • Breaking

    Type#getArrayType() is now Type#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 #value and will only return #initializer. #value should be seen as more of a convenience property for setting the initializer.

  • Breaking

    Symbol#getXByName-like methods were renamed to Symbol#getX.

  • Breaking

    Project#applyFileTextChanges() has moved to FileTextChanges#applyChanges().

  • Breaking

    SourceFile#getLineNumberAtPos is now SourceFile#getLineAndColumnAtPos

  • Breaking

    JsxText#containsOnlyWhiteSpaces() is now #containsOnlyTriviaWhiteSpaces(). FileSystemHost requires realpathSync.

  • Breaking

    Removed VariableDeclarationListStructure and VariableDeclarationList#set and #getStructure. This was done to simplify the structures.

  • Breaking

    The library now targets ES2015.

  • Breaking

    JsxAttributeStructure and JsxSpreadAttributeStructure are now differentiated based on their .kind property.

  • Breaking

    JsxElementStructure and JsxSelfClosingElementStructure are now differentiated based on their .kind property.

  • 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.