🚧 Still under progress. Soon will be finished.

ModuleNode

CLASS code

Description

Represents a reflected module as a collection of imports, exports and class/interface/function/type-alias/enum declarations

Methods

  • getTSNode

    code

    The original TypeScript node

    getTSNode(): SourceFile

    Returns

    SourceFile:

    The TypeScript AST node associated with this module

  • getSourcePath

    code

    The path to the source file for this module relative to the current working directory

    getSourcePath(): string

    Returns

    string:

    The relative path where the module is located

  • getOutputPath

    code

    The path where the JS file will be output by the TypeScript Compiler

    getOutputPath(): string

    Returns

    string:

    The relative path where the TypeScript compiler would emit the JS module. If the source file is a JS file, it returns the source path.

  • getContext

    code

    The context includes useful APIs that are shared across all the reflected symbols. Some APIs include the parsed configuration options, the system interface, the type checker

    getContext(): ProjectContext

    Returns

    ProjectContext:

    The analyser context

  • getImports

    code

    All the import declarations found in the source file

    getImports(): ImportNode[]

    Returns

    ImportNode[]:

    The reflected import declarations

  • getExports

    code

    All the export declarations found in the source file

    getExports(): ExportNode[]

    Returns

    ExportNode[]:

    The reflected export declarations

  • getDeclarations

    code

    All the class/interface/function/type-alias/enum declarations found in the source file

    getDeclarations(): DeclarationNode<Declaration, Node>[]

    Returns

    DeclarationNode<Declaration, Node>[]:

    The reflected declaration nodes

  • getJSDoc

    code

    Reflects the module-level JSDoc comment

    getJSDoc(): CommentNode

    Returns

    CommentNode:

    The module-level JSDoc comment blocks for a given source file.

  • getDeclarationByKind

    code

    Finds a declaration based on it’s kind

    getDeclarationByKind(kind: DeclarationKind): DeclarationNode<Declaration, Node>[]

    Parameters

    kind DeclarationKind

    The declaration kind

    Returns

    DeclarationNode<Declaration, Node>[]:

    All declaration nodes found

  • getDeclarationByName

    code

    Finds a declaration based on it’s name

    getDeclarationByName(name: string): DeclarationNode<Declaration, Node> | null

    Parameters

    name string

    The declaration name

    Returns

    DeclarationNode<Declaration, Node> | null:

    The matched declaration found if any

  • getDeclarationsByCategory

    code
    getDeclarationsByCategory(category: string): DeclarationNode<Declaration, Node>[]

    Parameters

    category string

    Returns

    DeclarationNode<Declaration, Node>[]:
  • serialize

    code

    Serializes the reflected node

    serialize(): Module

    Returns

    Module:

    The reflected node as a serializable object