diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9032877075..402674908b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -138,6 +138,9 @@ namespace ts { node = getParseTreeNode(node, isExportSpecifier); return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; }, + getExportSymbolOfSymbol(symbol) { + return getMergedSymbol(symbol.exportSymbol || symbol); + }, getTypeAtLocation: node => { node = getParseTreeNode(node); return node ? getTypeOfNode(node) : unknownType; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0a09bb5b6e..2b3e5ab36d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2568,6 +2568,15 @@ namespace ts { getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined; getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined; + /** + * 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. + */ + getExportSymbolOfSymbol(symbol: Symbol): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined; getTypeAtLocation(node: Node): Type; getTypeFromTypeNode(node: TypeNode): Type;