ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
39 lines (38 loc) • 1.54 kB
TypeScript
import * as ts from "typescript";
import { Constructor } from "./../../Constructor";
import { Node } from "./../common";
export declare type ModiferableNodeExtensionType = Node;
export declare type ModifierTexts = "export" | "default" | "declare" | "abstract" | "public" | "protected" | "private" | "readonly" | "static" | "async" | "const";
export interface ModifierableNode {
/**
* Gets the node's modifiers.
*/
getModifiers(): Node[];
/**
* Gets the first modifier of the specified syntax kind or throws if none found.
* @param kind - Syntax kind.
*/
getFirstModifierByKindOrThrow(kind: ts.SyntaxKind): Node<ts.Modifier>;
/**
* Gets the first modifier of the specified syntax kind or undefined if none found.
* @param kind - Syntax kind.
*/
getFirstModifierByKind(kind: ts.SyntaxKind): Node<ts.Modifier> | undefined;
/**
* Gets if it has the specified modifier.
* @param kind - Syntax kind to check for.
*/
hasModifier(kind: ts.SyntaxKind): boolean;
/**
* Gets if it has the specified modifier.
* @param text - Text to check for.
*/
hasModifier(text: ModifierTexts): boolean;
/**
* Toggles a modifier.
* @param text - Text to toggle the modifier for.
* @param value - Optional toggling value.
*/
toggleModifier(text: ModifierTexts, value?: boolean): this;
}
export declare function ModifierableNode<T extends Constructor<ModiferableNodeExtensionType>>(Base: T): Constructor<ModifierableNode> & T;