UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

116 lines (115 loc) 3.51 kB
import * as ts from "typescript"; import { Node, CallExpression, Expression, Identifier } from "./../common"; import { TypeNode } from "./../type"; export declare const DecoratorBase: typeof Node; export declare class Decorator extends DecoratorBase<ts.Decorator> { /** * Gets the decorator name. */ getName(): string; /** * Gets the name node of the decorator. */ getNameNode(): Identifier; /** * Gets the full decorator name. */ getFullName(): string; /** * Gets if the decorator is a decorator factory. */ isDecoratorFactory(): boolean; /** * Set if this decorator is a decorator factory. * @param isDecoratorFactory - If it should be a decorator factory or not. */ setIsDecoratorFactory(isDecoratorFactory: boolean): this; /** * Gets the call expression if a decorator factory, or throws. */ getCallExpressionOrThrow(): CallExpression; /** * Gets the call expression if a decorator factory. */ getCallExpression(): CallExpression | undefined; /** * Gets the expression. */ getExpression(): Expression<ts.LeftHandSideExpression>; /** * Gets the decorator's arguments from its call expression. */ getArguments(): Node[]; /** * Gets the decorator's type arguments from its call expression. */ getTypeArguments(): TypeNode[]; /** * Adds a type argument. * @param argumentTexts - Argument text. */ addTypeArgument(argumentText: string): TypeNode<ts.TypeNode>; /** * Adds type arguments. * @param argumentTexts - Argument texts. */ addTypeArguments(argumentTexts: string[]): TypeNode<ts.TypeNode>[]; /** * Inserts a type argument. * @param index - Index to insert at. * @param argumentTexts - Argument text. */ insertTypeArgument(index: number, argumentText: string): TypeNode<ts.TypeNode>; /** * Inserts type arguments. * @param index - Index to insert at. * @param argumentTexts - Argument texts. */ insertTypeArguments(index: number, argumentTexts: string[]): TypeNode<ts.TypeNode>[]; /** * Removes a type argument. * @param typeArg - Type argument to remove. */ removeTypeArgument(typeArg: Node): this; /** * Removes a type argument. * @param index - Index to remove. */ removeTypeArgument(index: number): this; /** * Adds an argument. * @param argumentTexts - Argument text. */ addArgument(argumentText: string): Node<ts.Node>; /** * Adds arguments. * @param argumentTexts - Argument texts. */ addArguments(argumentTexts: string[]): Node<ts.Node>[]; /** * Inserts an argument. * @param index - Index to insert at. * @param argumentTexts - Argument text. */ insertArgument(index: number, argumentText: string): Node<ts.Node>; /** * Inserts arguments. * @param index - Index to insert at. * @param argumentTexts - Argument texts. */ insertArguments(index: number, argumentTexts: string[]): Node<ts.Node>[]; /** * Removes an argument based on the node. * @param node - Argument's node to remove. */ removeArgument(node: Node): this; /** * Removes an argument based on the specified index. * @param index - Index to remove. */ removeArgument(index: number): this; /** * Removes this decorator. */ remove(): void; }