mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Don't re-alias top-level type aliases with local type aliases (#43701)
* No re-aliasing of top-level type aliases with local type aliases * Accept new baselines
This commit is contained in:
@@ -12834,12 +12834,22 @@ namespace ts {
|
||||
typeParameters.length);
|
||||
return errorType;
|
||||
}
|
||||
// We refrain from associating a local type alias with an instantiation of a top-level type alias
|
||||
// because the local alias may end up being referenced in an inferred return type where it is not
|
||||
// accessible--which in turn may lead to a large structural expansion of the type when generating
|
||||
// a .d.ts file. See #43622 for an example.
|
||||
const aliasSymbol = getAliasSymbolForTypeNode(node);
|
||||
return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
|
||||
const newAliasSymbol = aliasSymbol && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol)) ? aliasSymbol : undefined;
|
||||
return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol));
|
||||
}
|
||||
return checkNoTypeArguments(node, symbol) ? type : errorType;
|
||||
}
|
||||
|
||||
function isLocalTypeAlias(symbol: Symbol) {
|
||||
const declaration = symbol.declarations?.find(isTypeAlias);
|
||||
return !!(declaration && getContainingFunction(declaration));
|
||||
}
|
||||
|
||||
function getTypeReferenceName(node: TypeReferenceType): EntityNameOrEntityNameExpression | undefined {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeReference:
|
||||
|
||||
Reference in New Issue
Block a user