Skip to main content
Module

x/ts_morph/mod.ts>Symbol

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

Constructors

new
private
Symbol()

Properties

readonly
compilerSymbol: ts.Symbol

Gets the underlying compiler symbol.

Methods

getAliasedSymbol(): Symbol | undefined

Gets the aliased symbol or returns undefined if it doesn't exist.

getAliasedSymbolOrThrow(message?: string | (() => string)): Symbol

Gets the aliased symbol or throws if it doesn't exist.

getDeclarations(): Node[]

Gets the symbol declarations.

Gets the declared type of the symbol.

getEscapedName(): string

Gets the escaped name.

getExport(name: string): Symbol | undefined

Gets the export of the symbol by the specified name or returns undefined if not exists.

getExportOrThrow(name: string, message?: string | (() => string)): Symbol

Gets the export of the symbol by the specified name or throws if not exists.

getExports(): Symbol[]

Gets the exports from the symbol.

getExportSymbol(): Symbol

Gets the export symbol of the symbol if its a local symbol with a corresponding export symbol. Otherwise returns the current 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 getExportSymbol on that local symbol will return the exported symbol.

getFlags(): SymbolFlags

Gets the symbol flags.

Gets the fully qualified name.

getGlobalExport(name: string): Symbol | undefined

Gets the global export of the symbol by the specified name or returns undefined if not exists.

getGlobalExportOrThrow(name: string, message?: string | (() => string)): Symbol

Gets the global export of the symbol by the specified name or throws if not exists.

getGlobalExports(): Symbol[]

Gets the global exports from the symbol.

getImmediatelyAliasedSymbol(): Symbol | undefined

Follows a single alias to get the immediately aliased symbol or returns undefined if it doesn't exist.

getImmediatelyAliasedSymbolOrThrow(message?: string | (() => string)): Symbol

Follows a single alias to get the immediately aliased symbol or throws if it doesn't exist.

getJsDocTags(): JSDocTagInfo[]

Gets the JS doc tag infos of the symbol.

getMember(name: string): Symbol | undefined

Gets the member of the symbol by the specified name or returns undefined if not exists.

getMemberOrThrow(name: string, message?: string | (() => string)): Symbol

Gets the member of the symbol by the specified name or throws if not exists.

getMembers(): Symbol[]

Gets the members of the symbol

getName(): string

Gets the symbol name.

getTypeAtLocation(node: Node): Type<ts.Type>

Gets the type of the symbol at a location.

getValueDeclaration(): Node | undefined

Gets the value declaration of the symbol or returns undefined if it doesn't exist.

getValueDeclarationOrThrow(message?: string | (() => string)): Node

Gets the value declaration of a symbol or throws if it doesn't exist.

hasFlags(flags: SymbolFlags): boolean

Gets if the symbol has the specified flags.

isAlias(): boolean

Gets if the symbol is an alias.

isOptional(): boolean

Gets if the symbol is optional.