Skip to content

28.0.0

Latest

Choose a tag to compare

@dsherret dsherret released this 12 Apr 18:02
· 2 commits to latest since this release
c895bee

What's Changed

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 printStructure function.

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

Full Changelog: 27.0.2...28.0.0