UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

31 lines (30 loc) 925 B
import * as ts from "typescript"; import { Constructor } from "./../../../Constructor"; import { Node, Identifier } from "./../../common"; export declare type NameableNodeExtensionType = Node<ts.Node & { name?: ts.Identifier; }>; export interface NameableNode { /** * Gets the name node if it exists. */ getNameNode(): Identifier | undefined; /** * Gets the name node if it exists, or throws. */ getNameNodeOrThrow(): Identifier; /** * Gets the name if it exists. */ getName(): string | undefined; /** * Gets the name if it exists, or throws. */ getNameOrThrow(): string; /** * Renames the name or sets the name if it doesn't exist. * @param newName - New name. */ rename(newName: string): this; } export declare function NameableNode<T extends Constructor<NameableNodeExtensionType>>(Base: T): Constructor<NameableNode> & T;