mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 10:46:28 -05:00
return baseType in getSubstitutionType when baseType is any (#52573)
This commit is contained in:
@@ -15227,7 +15227,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)}`;
|
||||
|
||||
11
tests/baselines/reference/conditionalTypeAnyUnion.js
Normal file
11
tests/baselines/reference/conditionalTypeAnyUnion.js
Normal file
@@ -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
tests/baselines/reference/conditionalTypeAnyUnion.symbols
Normal file
16
tests/baselines/reference/conditionalTypeAnyUnion.symbols
Normal file
@@ -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
tests/baselines/reference/conditionalTypeAnyUnion.types
Normal file
12
tests/baselines/reference/conditionalTypeAnyUnion.types
Normal file
@@ -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
tests/cases/compiler/conditionalTypeAnyUnion.ts
Normal file
8
tests/cases/compiler/conditionalTypeAnyUnion.ts
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user