ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
27 lines (26 loc) • 996 B
TypeScript
import * as ts from "typescript";
import CodeBlockWriter from "code-block-writer";
import { Constructor } from "./../../Constructor";
import { Node } from "./../common";
export declare type BodyableNodeExtensionType = Node<ts.Node>;
export interface BodyableNode {
/**
* Gets the body or throws an error if it doesn't exist.
*/
getBodyOrThrow(): Node;
/**
* Gets the body if it exists.
*/
getBody(): Node | undefined;
/**
* Sets the body text. A body is required to do this operation.
* @param writerFunction - Function for using a writer to write out the body text.
*/
setBodyText(writerFunction: (writer: CodeBlockWriter) => void): this;
/**
* Sets the body text. A body is required to do this operation.
* @param text - Text to set as the body.
*/
setBodyText(text: string): this;
}
export declare function BodyableNode<T extends Constructor<BodyableNodeExtensionType>>(Base: T): Constructor<BodyableNode> & T;