Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15217,7 +15217,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}

function getSubstitutionType(baseType: Type, constraint: Type) {
if (constraint.flags & TypeFlags.AnyOrUnknown || constraint === baseType) {
if (constraint.flags & TypeFlags.AnyOrUnknown || constraint === baseType || baseType.flags & TypeFlags.Any) {
return baseType;
}
const id = `${getTypeId(baseType)}>${getTypeId(constraint)}`;
Expand Down
11 changes: 11 additions & 0 deletions tests/baselines/reference/conditionalTypeAnyUnion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//// [conditionalTypeAnyUnion.ts]
// repro from #52568

type Spec = any extends object ? any : string;

type WithSpec<T extends number> = T

type R = WithSpec<Spec> // should not error

//// [conditionalTypeAnyUnion.js]
// repro from #52568
16 changes: 16 additions & 0 deletions tests/baselines/reference/conditionalTypeAnyUnion.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
=== tests/cases/compiler/conditionalTypeAnyUnion.ts ===
// repro from #52568

type Spec = any extends object ? any : string;
>Spec : Symbol(Spec, Decl(conditionalTypeAnyUnion.ts, 0, 0))

type WithSpec<T extends number> = T
>WithSpec : Symbol(WithSpec, Decl(conditionalTypeAnyUnion.ts, 2, 46))
>T : Symbol(T, Decl(conditionalTypeAnyUnion.ts, 4, 14))
>T : Symbol(T, Decl(conditionalTypeAnyUnion.ts, 4, 14))

type R = WithSpec<Spec> // should not error
>R : Symbol(R, Decl(conditionalTypeAnyUnion.ts, 4, 35))
>WithSpec : Symbol(WithSpec, Decl(conditionalTypeAnyUnion.ts, 2, 46))
>Spec : Symbol(Spec, Decl(conditionalTypeAnyUnion.ts, 0, 0))

12 changes: 12 additions & 0 deletions tests/baselines/reference/conditionalTypeAnyUnion.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
=== tests/cases/compiler/conditionalTypeAnyUnion.ts ===
// repro from #52568

type Spec = any extends object ? any : string;
>Spec : any

type WithSpec<T extends number> = T
>WithSpec : T

type R = WithSpec<Spec> // should not error
>R : any

8 changes: 8 additions & 0 deletions tests/cases/compiler/conditionalTypeAnyUnion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

// repro from #52568

type Spec = any extends object ? any : string;

type WithSpec<T extends number> = T

type R = WithSpec<Spec> // should not error