UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

139 lines (138 loc) 3.64 kB
import * as ts from "typescript"; import { Node } from "./../common/Node"; import { Symbol } from "./../common/Symbol"; import { Signature } from "./../common/Signature"; export declare class Type<TType extends ts.Type = ts.Type> { /** * Gets the underlying compiler type. */ readonly compilerType: TType; /** * Gets the type text. * @param enclosingNode - The enclosing node. * @param typeFormatFlags - Format flags for the type text. */ getText(enclosingNode?: Node, typeFormatFlags?: ts.TypeFormatFlags): string; /** * Gets the alias symbol if it exists. */ getAliasSymbol(): Symbol | undefined; /** * Gets the alias type arguments. */ getAliasTypeArguments(): Type[]; /** * Gets the apparent type. */ getApparentType(): Type<ts.Type>; /** * Gets the array type */ getArrayType(): Type<ts.Type> | undefined; /** * Gets the base types. */ getBaseTypes(): Type<ts.Type>[]; /** * Gets the call signatures. */ getCallSignatures(): Signature[]; /** * Gets the construct signatures. */ getConstructSignatures(): Signature[]; /** * Gets the properties of the type. */ getProperties(): Symbol[]; /** * Gets a property. * @param name - By a name. * @param findFunction - Function for searching for a property. */ getProperty(name: string): Symbol | undefined; getProperty(findFunction: (declaration: Symbol) => boolean): Symbol | undefined; /** * Gets the apparent properties of the type. */ getApparentProperties(): Symbol[]; /** * Gets an apparent property. * @param name - By a name. * @param findFunction - Function for searching for an apparent property. */ getApparentProperty(name: string): Symbol | undefined; getApparentProperty(findFunction: (declaration: Symbol) => boolean): Symbol | undefined; /** * Gets the non-nullable type. */ getNonNullableType(): Type; /** * Gets the number index type. */ getNumberIndexType(): Type | undefined; /** * Gets the string index type. */ getStringIndexType(): Type | undefined; /** * Gets type arguments. */ getTypeArguments(): Type[]; /** * Gets the union types. */ getUnionTypes(): Type[]; /** * Gets the intersection types. */ getIntersectionTypes(): Type[]; /** * Gets the symbol of the type. */ getSymbol(): Symbol | undefined; /** * Gets if this is an anonymous type. */ isAnonymousType(): boolean; /** * Gets if this is an array type. */ isArrayType(): boolean; /** * Gets if this is a boolean type. */ isBooleanType(): boolean; /** * Gets if this is an enum type. */ isEnumType(): this is Type<ts.EnumType>; /** * Gets if this is an interface type. */ isInterfaceType(): this is Type<ts.InterfaceType>; /** * Gets if this is an intersection type. */ isIntersectionType(): this is Type<ts.UnionOrIntersectionType>; /** * Gets if this is an object type. */ isObjectType(): this is Type<ts.ObjectType>; /** * Gets if this is a union type. */ isUnionType(): this is Type<ts.UnionOrIntersectionType>; /** * Gets if this is the undefined type. */ isUndefinedType(): boolean; /** * Gets the type flags. */ getFlags(): ts.TypeFlags; /** * Gets the object flags. */ getObjectFlags(): ts.ObjectFlags | 0; }