Module

x/ts_morph/mod.ts>TypeChecker

TypeScript Compiler API wrapper for static analysis and programmatic code changes.
Very Popular
Go to Latest
class TypeChecker
import { TypeChecker } from "https://dotland.deno.dev/x/ts_morph@18.0.0/mod.ts";

Wrapper around the TypeChecker.

Constructors

new
private
TypeChecker()

Properties

readonly
compilerObject: ts.TypeChecker

Gets the compiler's TypeChecker.

Methods

getAliasedSymbol(symbol: Symbol): Symbol | undefined

Gets the aliased symbol of a symbol.

Gets the ambient module symbols (ex. modules in the @types folder or node_modules).

getApparentType(type: Type): Type<ts.Type>

Gets the apparent type of a type.

Gets the base type of a literal type.

For example, for a number literal type it will return the number type.

getConstantValue(node: EnumMember): string | number | undefined

Gets the constant value of a declaration.

getContextualType(expression: Expression): Type | undefined

Gets the contextual type of an expression.

Gets the declared type of a symbol.

getExportsOfModule(moduleSymbol: Symbol): Symbol[]

Gets the exports of a module.

Gets the local target symbol of the provided export specifier.

Gets the export symbol of a local symbol with a corresponding export symbol. Otherwise returns the input symbol.

The following is from the compiler API documentation:

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.

getFullyQualifiedName(symbol: Symbol): string

Gets the fully qualified name of a symbol.

Follow a single alias to get the immediately aliased symbol.

Gets the properties of a type.

Gets the resolved signature from a node or returns undefined if the signature can't be resolved.

getResolvedSignatureOrThrow(node: CallLikeExpression, message?: string | (() => string)): Signature

Gets the resolved signature from a node or throws if the signature cannot be resolved.

Gets the return type of a signature.

getSignatureFromNode(node: Node<ts.SignatureDeclaration>): Signature | undefined

Gets a signature from a node.

getSymbolAtLocation(node: Node): Symbol | undefined

Gets the symbol at the specified location or undefined if none exists.

Gets the symbols in the scope of the provided node.

Note: This will always return the local symbols. If you want the export symbol from a local symbol, then use the #getExportSymbolOfSymbol(symbol) method.

getTypeArguments(typeReference: Type): Type<ts.Type>[]

Gets the type arguments from a type reference.

Gets the type at the specified location.

Gets the type of a symbol at the specified location.

getTypeText(
type: Type,
enclosingNode?: Node,
typeFormatFlags?: TypeFormatFlags,
): string

Gets the type text