UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

38 lines (37 loc) 1.43 kB
import * as ts from "typescript"; import { Constructor } from "./../../Constructor"; import { DecoratorStructure } from "./../../structures"; import { Node } from "./../common"; import { Decorator } from "./../decorator/Decorator"; export declare type DecoratableNodeExtensionType = Node<ts.Node & { decorators: ts.NodeArray<ts.Decorator> | undefined; }>; export interface DecoratableNode { /** * Gets all the decorators of the node. */ getDecorators(): Decorator[]; /** * Adds a decorator. * @param structure - Structure of the decorator. */ addDecorator(structure: DecoratorStructure): Decorator; /** * Adds decorators. * @param structures - Structures of the decorators. */ addDecorators(structures: DecoratorStructure[]): Decorator[]; /** * Inserts a decorator. * @param index - Index to insert at. Specify a negative index to insert from the reverse. * @param structure - Structure of the decorator. */ insertDecorator(index: number, structure: DecoratorStructure): Decorator; /** * Insert decorators. * @param index - Index to insert at. * @param structures - Structures to insert. */ insertDecorators(index: number, structures: DecoratorStructure[]): Decorator[]; } export declare function DecoratableNode<T extends Constructor<DecoratableNodeExtensionType>>(Base: T): Constructor<DecoratableNode> & T;