TypeChecker

sealed external interface TypeChecker(source)

Properties

Link copied to clipboard
abstract var getIndexInfosOfIndexSymbol: (indexSymbol: Symbol) -> ReadonlyArray<IndexInfo>

Functions

Link copied to clipboard
abstract fun getAliasedSymbol(symbol: Symbol): Symbol

Follow all aliases to get the original symbol.

Link copied to clipboard
Link copied to clipboard
abstract fun getAnyType(): Type

Gets the intrinsic any type. There are multiple types that act as any used internally in the compiler, so the type returned by this function should not be used in equality checks to determine if another type is any. Instead, use type.flags & TypeFlags.Any.

Link copied to clipboard
abstract fun getApparentType(type: Type): Type
Link copied to clipboard
Link copied to clipboard
abstract fun getBaseConstraintOfType(type: Type): Type?
Link copied to clipboard
abstract fun getBaseTypeOfLiteralType(type: Type): Type
Link copied to clipboard
Link copied to clipboard
abstract fun getBigIntType(): Type
Link copied to clipboard
abstract fun getBooleanType(): Type
Link copied to clipboard
Link copied to clipboard
abstract fun getContextualType(node: Expression): Type?
Link copied to clipboard
abstract fun getDeclaredTypeOfSymbol(symbol: Symbol): Type
Link copied to clipboard
abstract fun getDefaultFromTypeParameter(type: Type): Type?
Link copied to clipboard
abstract fun getESSymbolType(): Type
Link copied to clipboard
abstract fun getExportsOfModule(moduleSymbol: Symbol): ReadonlyArray<Symbol>
Link copied to clipboard
abstract fun getExportSymbolOfSymbol(symbol: Symbol): Symbol

If a symbol is a local symbol with an associated exported symbol, returns the exported symbol. Otherwise returns its input. For example, at export type T = number;: - getSymbolAtLocation at the location T will return the exported symbol for T. - But the result of getSymbolsInScope will contain the local symbol for T, not the exported symbol. - Calling getExportSymbolOfSymbol on that local symbol will return the exported symbol.

Link copied to clipboard
abstract fun getFalseType(): Type
Link copied to clipboard
abstract fun getFullyQualifiedName(symbol: Symbol): String
Link copied to clipboard
abstract fun getImmediateAliasedSymbol(symbol: Symbol): Symbol?

Follow a single alias to get the immediately aliased symbol.

Link copied to clipboard
abstract fun getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo?
Link copied to clipboard
Link copied to clipboard
abstract fun getIndexTypeOfType(type: Type, kind: IndexKind): Type?
Link copied to clipboard
Link copied to clipboard
abstract fun getMergedSymbol(symbol: Symbol): Symbol
Link copied to clipboard
abstract fun getNeverType(): Type

Gets the intrinsic never type. There are multiple types that act as never used internally in the compiler, so the type returned by this function should not be used in equality checks to determine if another type is never. Instead, use type.flags & TypeFlags.Never.

Link copied to clipboard
abstract fun getNonNullableType(type: Type): Type
Link copied to clipboard
abstract fun getNullableType(type: Type, flags: TypeFlags): Type
Link copied to clipboard
abstract fun getNullType(): Type

Gets the intrinsic null type. There are multiple types that act as null used internally in the compiler, so the type returned by this function should not be used in equality checks to determine if another type is null. Instead, use type.flags & TypeFlags.Null.

Link copied to clipboard
Link copied to clipboard
abstract fun getNumberType(): Type
Link copied to clipboard
abstract fun getPrivateIdentifierPropertyOfType(leftType: Type, name: String, location: Node): Symbol?
Link copied to clipboard
Link copied to clipboard
abstract fun getPropertyOfType(type: Type, propertyName: String): Symbol?
Link copied to clipboard
abstract fun getResolvedSignature(node: CallLikeExpression, candidatesOutArray: ReadonlyArray<Signature> = definedExternally, argumentCount: Double = definedExternally): Signature?

returns unknownSignature in the case of an error. returns undefined if the node is not valid.

Link copied to clipboard
abstract fun getReturnTypeOfSignature(signature: Signature): Type
Link copied to clipboard
abstract fun getRootSymbols(symbol: Symbol): ReadonlyArray<Symbol>
Link copied to clipboard
abstract fun getShorthandAssignmentValueSymbol(location: Node?): Symbol?

The function returns the value (local variable) symbol of an identifier in the short-hand property assignment. This is necessary as an identifier in short-hand property assignment can contains two meaning: property name and property value.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract fun getStringType(): Type
Link copied to clipboard
abstract fun getSymbolAtLocation(node: Node): Symbol?
Link copied to clipboard
abstract fun getSymbolOfExpando(node: Node, allowDeclaration: Boolean): Symbol?
Link copied to clipboard
abstract fun getSymbolsInScope(location: Node, meaning: SymbolFlags): ReadonlyArray<Symbol>
Link copied to clipboard
abstract fun getTrueType(): Type
Link copied to clipboard
Link copied to clipboard
abstract fun getTypeAtLocation(node: Node): Type
Link copied to clipboard
abstract fun getTypeFromTypeNode(node: TypeNode): Type
Link copied to clipboard
Link copied to clipboard
abstract fun getTypeOfSymbol(symbol: Symbol): Type
Link copied to clipboard
abstract fun getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type
Link copied to clipboard
Link copied to clipboard
abstract fun getUndefinedType(): Type

Gets the intrinsic undefined type. There are multiple types that act as undefined used internally in the compiler depending on compiler options, so the type returned by this function should not be used in equality checks to determine if another type is undefined. Instead, use type.flags & TypeFlags.Undefined.

Link copied to clipboard
abstract fun getVoidType(): Type
Link copied to clipboard
abstract fun getWidenedType(type: Type): Type
Link copied to clipboard
abstract fun indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, enclosingDeclaration: Node?, flags: NodeBuilderFlags?): IndexSignatureDeclaration?

Note that the resulting nodes cannot be checked.

Link copied to clipboard
abstract fun isArgumentsSymbol(symbol: Symbol): Boolean
Link copied to clipboard
abstract fun isArrayLikeType(type: Type): Boolean

True if this type is assignable to ReadonlyArray<any>.

Link copied to clipboard
abstract fun isArrayType(type: Type): Boolean

True if this type is the Array or ReadonlyArray type from lib.d.ts. This function will not return true if passed a type which extends Array (for example, the TypeScript AST's NodeArray type).

Link copied to clipboard
Link copied to clipboard
abstract fun isTupleType(type: Type): Boolean

True if this type is a tuple type. This function will not return true if passed a type which extends from a tuple.

Link copied to clipboard
abstract fun isTypeAssignableTo(source: Type, target: Type): Boolean

Returns true if the "source" type is assignable to the "target" type.

Link copied to clipboard
abstract fun isUndefinedSymbol(symbol: Symbol): Boolean
Link copied to clipboard
abstract fun isUnknownSymbol(symbol: Symbol): Boolean
Link copied to clipboard
abstract fun isValidPropertyAccess(node: ImportTypeNode, propertyName: String): Boolean
abstract fun isValidPropertyAccess(node: PropertyAccessExpression, propertyName: String): Boolean
abstract fun isValidPropertyAccess(node: QualifiedName, propertyName: String): Boolean
Link copied to clipboard
abstract fun resolveName(name: String, location: Node?, meaning: SymbolFlags, excludeGlobals: Boolean): Symbol?
Link copied to clipboard
abstract fun <T> runWithCancellationToken(token: CancellationToken, cb: (checker: TypeChecker) -> T): T

Depending on the operation performed, it may be appropriate to throw away the checker if the cancellation token is triggered. Typically, if it is used for error checking and the operation is cancelled, then it should be discarded, otherwise it is safe to keep.

Link copied to clipboard

Note that the resulting nodes cannot be checked.

Link copied to clipboard
abstract fun signatureToString(signature: Signature, enclosingDeclaration: Node = definedExternally, flags: TypeFormatFlags = definedExternally, kind: SignatureKind = definedExternally): String
Link copied to clipboard
abstract fun symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node?, flags: NodeBuilderFlags?): EntityName?

Note that the resulting nodes cannot be checked.

Link copied to clipboard
abstract fun symbolToExpression(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node?, flags: NodeBuilderFlags?): Expression?

Note that the resulting nodes cannot be checked.

Link copied to clipboard
abstract fun symbolToParameterDeclaration(symbol: Symbol, enclosingDeclaration: Node?, flags: NodeBuilderFlags?): ParameterDeclaration?

Note that the resulting nodes cannot be checked.

Link copied to clipboard
abstract fun symbolToString(symbol: Symbol, enclosingDeclaration: Node = definedExternally, meaning: SymbolFlags = definedExternally, flags: SymbolFormatFlags = definedExternally): String
Link copied to clipboard
abstract fun symbolToTypeParameterDeclarations(symbol: Symbol, enclosingDeclaration: Node?, flags: NodeBuilderFlags?): NodeArray<TypeParameterDeclaration>?

Note that the resulting nodes cannot be checked.

Link copied to clipboard
abstract fun tryGetMemberInModuleExports(memberName: String, moduleSymbol: Symbol): Symbol?
Link copied to clipboard
abstract fun typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration: Node?, flags: NodeBuilderFlags?): TypeParameterDeclaration?

Note that the resulting nodes cannot be checked.

Link copied to clipboard
abstract fun typePredicateToString(predicate: TypePredicate, enclosingDeclaration: Node = definedExternally, flags: TypeFormatFlags = definedExternally): String
Link copied to clipboard
abstract fun typeToString(type: Type, enclosingDeclaration: Node = definedExternally, flags: TypeFormatFlags = definedExternally): String
Link copied to clipboard
abstract fun typeToTypeNode(type: Type, enclosingDeclaration: Node?, flags: NodeBuilderFlags?): TypeNode?

Note that the resulting nodes cannot be checked.