mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00: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:
1 parent
01264ac414
commit
0f2dabcd4b
3 files changed
+18
-8
No files matched your search
+11
-1
@@ -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