mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Check if module reference requires type reference before path reference (#25385)
This commit is contained in:
@@ -3747,7 +3747,7 @@ namespace ts {
|
||||
const ambientDecls = filter(symbol.declarations, isAmbientModule);
|
||||
if (length(ambientDecls)) {
|
||||
for (const decl of ambientDecls) {
|
||||
context.tracker.trackReferencedAmbientModule(decl);
|
||||
context.tracker.trackReferencedAmbientModule(decl, symbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function trackReferencedAmbientModule(node: ModuleDeclaration) {
|
||||
function trackReferencedAmbientModule(node: ModuleDeclaration, symbol: Symbol) {
|
||||
// If it is visible via `// <reference types="..."/>`, then we should just use that
|
||||
const directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, SymbolFlags.All);
|
||||
if (length(directives)) {
|
||||
return recordTypeReferenceDirectivesIfNecessary(directives);
|
||||
}
|
||||
// Otherwise we should emit a path-based reference
|
||||
const container = getSourceFileOfNode(node);
|
||||
refs.set("" + getOriginalNodeId(container), container);
|
||||
}
|
||||
|
||||
@@ -5316,7 +5316,7 @@ namespace ts {
|
||||
reportPrivateInBaseOfClassExpression?(propertyName: string): void;
|
||||
reportInaccessibleUniqueSymbolError?(): void;
|
||||
moduleResolverHost?: ModuleSpecifierResolutionHost;
|
||||
trackReferencedAmbientModule?(decl: ModuleDeclaration): void;
|
||||
trackReferencedAmbientModule?(decl: ModuleDeclaration, symbol: Symbol): void;
|
||||
}
|
||||
|
||||
export interface TextSpan {
|
||||
|
||||
Reference in New Issue
Block a user