mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 11:24:29 -05:00
Fix emit when type import merges with local value
This commit is contained in:
@@ -1473,8 +1473,15 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that a symbol is an alias that does not merge with a local declaration.
|
||||
*/
|
||||
function isNonLocalAlias(symbol: Symbol, excludes = SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace) {
|
||||
return symbol && (symbol.flags & (SymbolFlags.Alias | excludes)) === SymbolFlags.Alias;
|
||||
}
|
||||
|
||||
function resolveSymbol(symbol: Symbol, dontResolveAlias?: boolean): Symbol {
|
||||
const shouldResolve = !dontResolveAlias && symbol && symbol.flags & SymbolFlags.Alias && !(symbol.flags & (SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace));
|
||||
const shouldResolve = !dontResolveAlias && isNonLocalAlias(symbol);
|
||||
return shouldResolve ? resolveAlias(symbol) : symbol;
|
||||
}
|
||||
|
||||
@@ -12015,7 +12022,9 @@ namespace ts {
|
||||
return getTypeOfSymbol(symbol);
|
||||
}
|
||||
|
||||
if (symbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) {
|
||||
// We should only mark aliases as referenced if there isn't a local value declaration
|
||||
// for the symbol.
|
||||
if (isNonLocalAlias(symbol, /*excludes*/ SymbolFlags.Value) && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) {
|
||||
markAliasSymbolAsReferenced(symbol);
|
||||
}
|
||||
|
||||
@@ -22864,7 +22873,9 @@ namespace ts {
|
||||
node = getParseTreeNode(node, isIdentifier);
|
||||
if (node) {
|
||||
const symbol = getReferencedValueSymbol(node);
|
||||
if (symbol && symbol.flags & SymbolFlags.Alias) {
|
||||
// We should only get the declaration of an alias if there isn't a local value
|
||||
// declaration for the symbol
|
||||
if (isNonLocalAlias(symbol, /*excludes*/ SymbolFlags.Value)) {
|
||||
return getDeclarationOfAliasSymbol(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user