Skip to content

Commit f104b53

Browse files
committed
Revert changes and instead fix isGenericObjectType to be more conservative
1 parent dd88229 commit f104b53

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14078,7 +14078,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1407814078
else if (type !== firstType) {
1407914079
checkFlags |= CheckFlags.HasNonUniformType;
1408014080
}
14081-
if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) {
14081+
if (isLiteralType(type) || isPatternLiteralType(type)) {
1408214082
checkFlags |= CheckFlags.HasLiteralType;
1408314083
}
1408414084
if (type.flags & TypeFlags.Never && type !== uniqueLiteralType) {
@@ -17685,7 +17685,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1768517685
// eagerly using the constraint type of 'this' at the given location.
1768617686
if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== SyntaxKind.IndexedAccessType ?
1768717687
isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) :
17688-
isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)) || !(accessFlags & AccessFlags.ResolveReducibleTypes) && isGenericReducibleType(objectType))) {
17688+
isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)) || isGenericReducibleType(objectType))) {
1768917689
if (objectType.flags & TypeFlags.AnyOrUnknown) {
1769017690
return objectType;
1769117691
}
@@ -24511,15 +24511,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2451124511
}
2451224512
}
2451324513
}
24514-
// The following is a targeted fix to allow higher-kinded types to be emulated using the technique in #53970.
24515-
// Specifically, when an indexed access type was deferred because it has a reducible object type, here we force
24516-
// resolution of the type and then infer to the result.
24517-
if (target.flags & TypeFlags.IndexedAccess && isGenericReducibleType((target as IndexedAccessType).objectType)) {
24518-
const instantiated = getIndexedAccessType((target as IndexedAccessType).objectType, (target as IndexedAccessType).indexType, AccessFlags.ResolveReducibleTypes);
24519-
if (instantiated && instantiated !== target) {
24520-
inferFromTypes(source, instantiated);
24521-
}
24522-
}
2452324514
}
2452424515
if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (
2452524516
(source as TypeReference).target === (target as TypeReference).target || isArrayType(source) && isArrayType(target)) &&

src/compiler/types.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6593,16 +6593,15 @@ export interface TypeParameter extends InstantiableType {
65936593
export const enum AccessFlags {
65946594
None = 0,
65956595
IncludeUndefined = 1 << 0,
6596-
ResolveReducibleTypes = 1 << 1,
6597-
NoIndexSignatures = 1 << 2,
6598-
Writing = 1 << 3,
6599-
CacheSymbol = 1 << 4,
6600-
NoTupleBoundsCheck = 1 << 5,
6601-
ExpressionPosition = 1 << 6,
6602-
ReportDeprecated = 1 << 7,
6603-
SuppressNoImplicitAnyError = 1 << 8,
6604-
Contextual = 1 << 9,
6605-
Persistent = IncludeUndefined | ResolveReducibleTypes,
6596+
NoIndexSignatures = 1 << 1,
6597+
Writing = 1 << 2,
6598+
CacheSymbol = 1 << 3,
6599+
NoTupleBoundsCheck = 1 << 4,
6600+
ExpressionPosition = 1 << 5,
6601+
ReportDeprecated = 1 << 6,
6602+
SuppressNoImplicitAnyError = 1 << 7,
6603+
Contextual = 1 << 8,
6604+
Persistent = IncludeUndefined,
66066605
}
66076606

66086607
// Indexed access types (TypeFlags.IndexedAccess)

0 commit comments

Comments
 (0)