Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TypescriptMorpher

A component that wraps around ts-morph to be create/modify typescript files

Hierarchy

  • Component
    • TypescriptMorpher

Index

Constructors

constructor

  • Initializes a ts-morph project inside a given Projen project

    Parameters

    • project: NodeProject | TypeScriptAppProject | TypeScriptProject

      Projen project

    • Optional options: MorphProjectOptions

      Customization for ts-morph project

    Returns TypescriptMorpher

Properties

Private baseDirectory

baseDirectory: string

Readonly project

project: Project

Private temporaryFiles

temporaryFiles: SourceFile[]

Readonly tsProject

tsProject: Project

ts-morph project

Methods

createSampleTypescriptFile

  • createSampleTypescriptFile(filePath: string): undefined | SourceFile
  • Create a "sample" Typescript file. This file will only be generated once during the initial "projen new" command

    Parameters

    • filePath: string

    Returns undefined | SourceFile

    a Typescript file if created during project creation, otherwise undefined

createTemporaryTypescriptFile

  • createTemporaryTypescriptFile(fileName: string): SourceFile
  • Create an in-memory-only Typescript file. It will not be written to the filesystem.

    Parameters

    • fileName: string

      A filename that represent this source ("example.ts").

    Returns SourceFile

    a Typescript file. Use .print() to get the generated contents

createTypescriptFile

  • Create a Typescript file.

    Parameters

    • filePath: string

      path to create new typescript file at, relative to project root

    • Optional options: CreateTypescriptFileOptions

      Behavior of created file

    Returns SourceFile

    A new Typescript source

getTypescriptFile

  • getTypescriptFile(filePath: string): undefined | SourceFile
  • Gets an existing Typescript source file

    Parameters

    • filePath: string

      path to existing typescript file, relative to project root

    Returns undefined | SourceFile

    Typescript source file

getTypescriptFileOrThrow

  • getTypescriptFileOrThrow(filePath: string): SourceFile
  • Gets an existing Typescript source file (Throws if not found)

    throws

    FileNotFoundError when the file is not found.

    Parameters

    • filePath: string

      path to existing typescript file, relative to project root

    Returns SourceFile

    Typescript source file

postSynthesize

  • postSynthesize(): void
  • (experimental) Called after synthesis.

    Order is not guaranteed.

    experimental

    Returns void

preSynthesize

  • preSynthesize(): void
  • (experimental) Called before synthesis.

    experimental

    Returns void

renderFencedTypescript

  • renderFencedTypescript(source: SourceFile, options?: PrintNodeOptions): string
  • Renders the given source file as a fenced code block for markdown

    Parameters

    • source: SourceFile

      Typescript source to render

    • Optional options: PrintNodeOptions

      Customize output format

    Returns string

    String render of source

synthesize

  • synthesize(): void
  • Returns void

Generated using TypeDoc