This commit is contained in:
Anders Hejlsberg 2024-02-04 14:21:47 -08:00
Родитель ad0a847fd3
Коммит 81efc8630d
2 изменённых файлов: 9 добавлений и 7 удалений

Просмотреть файл

@ -16049,8 +16049,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// mapped type, and the instantiation occurs in a context where resolving type arguments might cause a
// circular reference, we create a deferred type alias instantiation. This acts as a proxy for the
// actual instantiation, which is obtained using getResolvedType.
if (getObjectFlags(type) & (ObjectFlags.Reference | ObjectFlags.Anonymous | ObjectFlags.Mapped) && node.kind === SyntaxKind.TypeReference &&
isDeferredTypeReferenceNode(node as TypeReferenceNode, length(node.typeArguments) !== typeParameters.length)) {
if (
getObjectFlags(type) & (ObjectFlags.Reference | ObjectFlags.Anonymous | ObjectFlags.Mapped) && node.kind === SyntaxKind.TypeReference &&
isDeferredTypeReferenceNode(node as TypeReferenceNode, length(node.typeArguments) !== typeParameters.length)
) {
return createDeferredTypeAliasInstantiation(symbol, node, newAliasSymbol, aliasTypeArguments);
}
return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, aliasTypeArguments);
@ -16723,8 +16725,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
function isDeferredTypeReferenceNode(node: TypeReferenceNode | ArrayTypeNode | TupleTypeNode, hasDefaultTypeArguments?: boolean) {
return isResolvedByTypeAlias(node) && (
node.kind === SyntaxKind.ArrayType ? mayResolveTypeAlias(node.elementType) :
node.kind === SyntaxKind.TupleType ? some(node.elements, mayResolveTypeAlias) :
hasDefaultTypeArguments || some(node.typeArguments, mayResolveTypeAlias)
node.kind === SyntaxKind.TupleType ? some(node.elements, mayResolveTypeAlias) :
hasDefaultTypeArguments || some(node.typeArguments, mayResolveTypeAlias)
);
}

Просмотреть файл

@ -6547,9 +6547,9 @@ export interface MappedType extends AnonymousType {
/** @internal */
export interface TypeAliasInstantiationType extends AnonymousType {
typeAlias: Symbol; // Type alias symbol
node: NodeWithTypeArguments; // Type alias instantiation node
resolvedType?: ObjectType; // Resolved type alias instantiation
typeAlias: Symbol; // Type alias symbol
node: NodeWithTypeArguments; // Type alias instantiation node
resolvedType?: ObjectType; // Resolved type alias instantiation
}
export interface EvolvingArrayType extends ObjectType {