{"name":"ts-morph","version":"27.0.0","keywords":["typescript","ast","static analysis","code generation","code refactor"],"author":{"name":"David Sherret"},"license":"MIT","_id":"ts-morph@27.0.0","maintainers":[{"name":"dsherret","email":"dsherret@gmail.com"}],"homepage":"https://github.com/dsherret/ts-morph#readme","bugs":{"url":"https://github.com/dsherret/ts-morph/issues"},"dist":{"shasum":"42e132b27187269dc4e0a725c1063bf9f553490d","tarball":"http://registry-npm.ywwl.com/ts-morph/download/ts-morph-27.0.0.tgz","fileCount":5,"integrity":"sha512-xcqelpTR5PCuZMs54qp9DE3t7tPgA2v/P1/qdW4ke5b3Y5liTGTYj6a/twT35EQW/H5okRqp1UOqwNlgg0K0eQ==","signatures":[{"sig":"MEUCIAwvm7kpiAX2SSJH+dVfuu6aoQCcZbFeViGWG3dNfxNaAiEAmH4W2uXCxXUNhc7gyS5xLPnOBBvRLW9rqmcBBETUoTY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/ts-morph@27.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":1466498,"size":201049,"noattachment":false,"key":"/ts-morph/-/ts-morph-27.0.0.tgz"},"main":"dist/ts-morph.js","types":"lib/ts-morph.d.ts","browser":{"fs":false,"os":false,"glob":false,"mkdirp":false,"dir-glob":false,"tinyglobby":false,"fs.realpath":false,"glob-parent":false,"graceful-fs":false,"source-map-support":false},"gitHead":"2182f9982a7e4a900212b4c74e5dc53b181a7d0a","scripts":{"test":"deno run -A npm:mocha","build":"deno task build:declarations && deno task build:node","package":"deno task build","test:ci":"deno task test","dopublish":"deno task type-check-docs && deno task code-generate && deno task package && deno task publish-code-verification && echo \"Run: npm publish\"","build:deno":"deno task build:declarations && rimraf dist-deno && rollup -c --environment BUILD:deno && deno run -A scripts/buildDeno.ts","build:node":"rimraf dist && rollup -c ","test:debug":"deno task test --inspect-brk","test:watch":"deno task test --watch-extensions ts --watch","type-check":"deno run -A scripts/typeCheckLibrary.ts","code-generate":"deno run -A scripts/generation/main.ts","type-check-docs":"deno run -A scripts/typeCheckDocumentation.ts","test:ts-versions":"deno run -A scripts/test/testTypeScriptVersions.ts","code-verification":"deno run -A scripts/verification/main.ts ensure-structures-match-classes ensure-overload-structures-match ensure-array-inputs-readonly ensure-classes-implement-structure-methods ensure-mixin-not-applied-multiple-times validate-public-api-class-member-names validate-compiler-node-to-wrapped-type validate-code-fences","build:declarations":"deno run -A scripts/generation/main.ts create-declaration-file","output-wrapped-nodes":"deno run -A scripts/generation/outputWrappedNodesInfo.ts","ensure-or-throw-exists":"deno run -A scripts/verification/main ensure-or-throw-exists.ts","publish-code-verification":"deno task code-verification && deno task ensure-no-declaration-file-errors","ensure-array-inputs-readonly":"deno run -A scripts/verification/main ensure-array-inputs-readonly.ts","ensure-structures-match-classes":"deno run -A scripts/verification/main.ts ensure-structures-match-classes","ensure-no-project-compile-errors":"deno run -A scripts/verification/ensureNoProjectCompileErrors.ts","ensure-overload-structures-match":"deno run -A scripts/verification/main.ts ensure-overload-structures-match","ensure-no-declaration-file-errors":"deno run -A scripts/verification/ensureNoDeclarationFileErrors.ts"},"_npmUser":{"name":"dsherret","email":"dsherret@gmail.com"},"repository":{"url":"git+https://github.com/dsherret/ts-morph.git","type":"git"},"_npmVersion":"10.9.3","description":"TypeScript compiler wrapper for static analysis and code manipulation.","directories":{},"_nodeVersion":"22.19.0","dependencies":{"@ts-morph/common":"~0.28.0","code-block-writer":"^13.0.3"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^5.2.0","diff":"^7.0.0","mocha":"11.1.0","rimraf":"^6.0.1","rollup":"=4.40.0","ts-node":"10.9.2","cross-env":"^7.0.3","typescript":"~5.9.2","@types/chai":"^5.2.1","@types/diff":"^7.0.2","@types/node":"^22.14.1","@types/mocha":"^10.0.10","conditional-type-checks":"^1.0.6","@rollup/plugin-typescript":"^12.1.2"},"_npmOperationalInternal":{"tmp":"tmp/ts-morph_27.0.0_1757278340966_0.13282361972009338","host":"s3://npm-registry-packages-npm-production"},"readme":"# <img src=\"logo.svg\" alt=\"ts-morph\" height=\"58\" />\n\n[![npm version](https://badge.fury.io/js/ts-morph.svg)](https://badge.fury.io/js/ts-morph)\n[![CI](https://github.com/dsherret/ts-morph/workflows/CI/badge.svg)](https://github.com/dsherret/ts-morph/actions?query=workflow%3ACI)\n[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)\n\n[TypeScript](https://github.com/Microsoft/TypeScript) Compiler API wrapper. Provides an easier way to programmatically navigate and manipulate TypeScript and JavaScript code.\n\nFormerly `ts-simple-ast`.\n\n## Overview\n\n- [Documentation](https://ts-morph.com/)\n- [Declaration file](https://github.com/dsherret/ts-morph/blob/latest/packages/ts-morph/lib/ts-morph.d.ts)\n\n## Main Features\n\n1. Wraps the compiler API objects to provide helper methods for getting information and programmatically changing files.\n2. Allows falling back to the compiler API objects if necessary (ex. `classDeclaration.compilerNode` or `typeChecker.compilerObject`).\n3. All changes are kept in memory (including file and directory moves) until specifying to save to the underlying file system.\n4. Changes are made to the text and wrapped nodes can be held on to between manipulations.\n\n## Getting Started\n\n1. [Installing](https://ts-morph.com/)\n2. [Instantiating](https://ts-morph.com/setup/)\n3. [Adding source files](https://ts-morph.com/setup/adding-source-files)\n4. [Getting source files](https://ts-morph.com/navigation/getting-source-files)\n5. [Navigating](https://ts-morph.com/navigation/example)\n6. [Manipulating](https://ts-morph.com/manipulation/)\n\n## Library Progress\n\nThis library is still under active development. Most common code manipulation/generation use cases are implemented, but there's still a lot of work to do. Please open an issue if you find a feature missing, bug, or question that isn't in the issue tracker.\n\n- [Breaking changes](https://github.com/dsherret/ts-morph/blob/latest/packages/ts-morph/breaking-changes.md)\n- [Change log](https://github.com/dsherret/ts-morph/blob/latest/packages/ts-morph/CHANGELOG.md)\n- [Wrapped nodes progress report](https://github.com/dsherret/ts-morph/blob/latest/packages/ts-morph/wrapped-nodes.md)\n\n## Example\n\n<!-- dprint-ignore -->\n```ts\nimport { Project, StructureKind } from \"ts-morph\";\n\n// initialize\nconst project = new Project({\n    // Optionally specify compiler options, tsconfig.json, in-memory file system, and more here.\n    // If you initialize with a tsconfig.json, then it will automatically populate the project\n    // with the associated source files.\n    // Read more: https://ts-morph.com/setup/\n});\n\n// add source files\nproject.addSourceFilesAtPaths(\"src/**/*.ts\");\nconst myClassFile = project.createSourceFile(\"src/MyClass.ts\", \"export class MyClass {}\");\nconst myEnumFile = project.createSourceFile(\"src/MyEnum.ts\", {\n    statements: [{\n        kind: StructureKind.Enum,\n        name: \"MyEnum\",\n        isExported: true,\n        members: [{ name: \"member\" }],\n    }],\n});\n\n// get information\nconst myClass = myClassFile.getClassOrThrow(\"MyClass\");\nmyClass.getName();          // returns: \"MyClass\"\nmyClass.hasExportKeyword(); // returns: true\nmyClass.isDefaultExport();  // returns: false\n\n// manipulate\nconst myInterface = myClassFile.addInterface({\n    name: \"IMyInterface\",\n    isExported: true,\n    properties: [{\n        name: \"myProp\",\n        type: \"number\",\n    }],\n});\n\nmyClass.rename(\"NewName\");\nmyClass.addImplements(myInterface.getName());\nmyClass.addProperty({\n    name: \"myProp\",\n    initializer: \"5\",\n});\n\nproject.getSourceFileOrThrow(\"src/ExistingFile.ts\").delete();\n\n// asynchronously save all the changes above\nawait project.save();\n\n// get underlying compiler node from the typescript AST from any node\nconst compilerNode = myClassFile.compilerNode;\n```\n\nOr navigate existing compiler nodes created with the TypeScript compiler (the `ts` named export is the TypeScript compiler):\n\n```ts ignore-error: 1109\nimport { createWrappedNode, ClassDeclaration, ts } from \"ts-morph\";\n\n// some code that creates a class declaration using the ts object\nconst classNode: ts.ClassDeclaration = ...;\n\n// create and use a wrapped node\nconst classDec = createWrappedNode(classNode) as ClassDeclaration;\nconst firstProperty = classDec.getProperties()[0];\n\n// ... do more stuff here ...\n```\n","publish_time":1757278341292,"_cnpm_publish_time":1757278341292,"dist-tags":{"latest":"28.0.0","rc":"2.0.4-rc"}}