UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

154 lines (153 loc) 6.94 kB
import * as ts from "typescript"; import { ConstructSignatureDeclarationStructure, MethodSignatureStructure, PropertySignatureStructure, InterfaceDeclarationStructure } from "./../../structures"; import { Node } from "./../common"; import { NamedNode, ExportableNode, ModifierableNode, AmbientableNode, DocumentationableNode, TypeParameteredNode, HeritageClauseableNode, ExtendsClauseableNode, TextInsertableNode } from "./../base"; import { NamespaceChildableNode } from "./../namespace"; import { ConstructSignatureDeclaration } from "./ConstructSignatureDeclaration"; import { MethodSignature } from "./MethodSignature"; import { PropertySignature } from "./PropertySignature"; export declare type InterfaceMemberTypes = PropertySignature | MethodSignature | ConstructSignatureDeclaration; export declare const InterfaceDeclarationBase: (new (...args: any[]) => TextInsertableNode) & (new (...args: any[]) => ExtendsClauseableNode) & (new (...args: any[]) => HeritageClauseableNode) & (new (...args: any[]) => TypeParameteredNode) & (new (...args: any[]) => DocumentationableNode) & (new (...args: any[]) => AmbientableNode) & (new (...args: any[]) => NamespaceChildableNode) & (new (...args: any[]) => ExportableNode) & (new (...args: any[]) => ModifierableNode) & (new (...args: any[]) => NamedNode) & typeof Node; export declare class InterfaceDeclaration extends InterfaceDeclarationBase<ts.InterfaceDeclaration> { /** * Fills the node from a structure. * @param structure - Structure to fill. */ fill(structure: Partial<InterfaceDeclarationStructure>): this; /** * Add construct signature. * @param structure - Structure representing the construct signature. */ addConstructSignature(structure: ConstructSignatureDeclarationStructure): ConstructSignatureDeclaration; /** * Add construct signatures. * @param structures - Structures representing the construct signatures. */ addConstructSignatures(structures: ConstructSignatureDeclarationStructure[]): ConstructSignatureDeclaration[]; /** * Insert construct signature. * @param index - Index to insert at. * @param structure - Structure representing the construct signature. */ insertConstructSignature(index: number, structure: ConstructSignatureDeclarationStructure): ConstructSignatureDeclaration; /** * Insert properties. * @param index - Index to insert at. * @param structures - Structures representing the construct signatures. */ insertConstructSignatures(index: number, structures: ConstructSignatureDeclarationStructure[]): ConstructSignatureDeclaration[]; /** * Gets the first construct signature by a find function. * @param findFunction - Function to find the construct signature by. */ getConstructSignature(findFunction: (member: ConstructSignatureDeclaration) => boolean): ConstructSignatureDeclaration | undefined; /** * Gets the first construct signature by a find function or throws if not found. * @param findFunction - Function to find the construct signature by. */ getConstructSignatureOrThrow(findFunction: (member: ConstructSignatureDeclaration) => boolean): ConstructSignatureDeclaration; /** * Gets the interface method signatures. */ getConstructSignatures(): ConstructSignatureDeclaration[]; /** * Add method. * @param structure - Structure representing the method. */ addMethod(structure: MethodSignatureStructure): MethodSignature; /** * Add methods. * @param structures - Structures representing the methods. */ addMethods(structures: MethodSignatureStructure[]): MethodSignature[]; /** * Insert method. * @param index - Index to insert at. * @param structure - Structure representing the method. */ insertMethod(index: number, structure: MethodSignatureStructure): MethodSignature; /** * Insert methods. * @param index - Index to insert at. * @param structures - Structures representing the methods. */ insertMethods(index: number, structures: MethodSignatureStructure[]): MethodSignature[]; /** * Gets the first method by name. * @param name - Name. */ getMethod(name: string): MethodSignature | undefined; /** * Gets the first method by a find function. * @param findFunction - Function to find the method by. */ getMethod(findFunction: (member: MethodSignature) => boolean): MethodSignature | undefined; /** * Gets the first method by name or throws if not found. * @param name - Name. */ getMethodOrThrow(name: string): MethodSignature; /** * Gets the first method by a find function or throws if not found. * @param findFunction - Function to find the method by. */ getMethodOrThrow(findFunction: (member: MethodSignature) => boolean): MethodSignature; /** * Gets the interface method signatures. */ getMethods(): MethodSignature[]; /** * Add property. * @param structure - Structure representing the property. */ addProperty(structure: PropertySignatureStructure): PropertySignature; /** * Add properties. * @param structures - Structures representing the properties. */ addProperties(structures: PropertySignatureStructure[]): PropertySignature[]; /** * Insert property. * @param index - Index to insert at. * @param structure - Structure representing the property. */ insertProperty(index: number, structure: PropertySignatureStructure): PropertySignature; /** * Insert properties. * @param index - Index to insert at. * @param structures - Structures representing the properties. */ insertProperties(index: number, structures: PropertySignatureStructure[]): PropertySignature[]; /** * Gets the first property by name. * @param name - Name. */ getProperty(name: string): PropertySignature | undefined; /** * Gets the first property by a find function. * @param findFunction - Function to find the property by. */ getProperty(findFunction: (member: PropertySignature) => boolean): PropertySignature | undefined; /** * Gets the first property by name or throws if not found. * @param name - Name. */ getPropertyOrThrow(name: string): PropertySignature; /** * Gets the first property by a find function or throws if not found. * @param findFunction - Function to find the property by. */ getPropertyOrThrow(findFunction: (member: PropertySignature) => boolean): PropertySignature; /** * Gets the interface property signatures. */ getProperties(): PropertySignature[]; /** * Gets all members. */ getAllMembers(): InterfaceMemberTypes[]; /** * Removes this interface declaration. */ remove(): void; }