Skip to content

Commit b83148f

Browse files
authored
Unwrap substitutions on conditional check types before comparing them (#43888)
1 parent 84da19e commit b83148f

5 files changed

+33
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15022,7 +15022,7 @@ namespace ts {
1502215022
// purposes of resolution. This means such types aren't subject to the instatiation depth limiter.
1502315023
while (true) {
1502415024
const isUnwrapped = isTypicalNondistributiveConditional(root);
15025-
const checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.checkType), mapper);
15025+
const checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
1502615026
const checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
1502715027
const extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
1502815028
if (checkType === wildcardType || extendsType === wildcardType) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//// [curiousNestedConditionalEvaluationResult.ts]
2+
// regression test for #43123
3+
type Hmm = [0] extends [infer T, any?] ?
4+
[T, [0] extends [T] ? true : false]
5+
: never
6+
7+
//// [curiousNestedConditionalEvaluationResult.js]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
=== tests/cases/compiler/curiousNestedConditionalEvaluationResult.ts ===
2+
// regression test for #43123
3+
type Hmm = [0] extends [infer T, any?] ?
4+
>Hmm : Symbol(Hmm, Decl(curiousNestedConditionalEvaluationResult.ts, 0, 0))
5+
>T : Symbol(T, Decl(curiousNestedConditionalEvaluationResult.ts, 1, 29))
6+
7+
[T, [0] extends [T] ? true : false]
8+
>T : Symbol(T, Decl(curiousNestedConditionalEvaluationResult.ts, 1, 29))
9+
>T : Symbol(T, Decl(curiousNestedConditionalEvaluationResult.ts, 1, 29))
10+
11+
: never
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/curiousNestedConditionalEvaluationResult.ts ===
2+
// regression test for #43123
3+
type Hmm = [0] extends [infer T, any?] ?
4+
>Hmm : [0, true]
5+
6+
[T, [0] extends [T] ? true : false]
7+
>true : true
8+
>false : false
9+
10+
: never
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// regression test for #43123
2+
type Hmm = [0] extends [infer T, any?] ?
3+
[T, [0] extends [T] ? true : false]
4+
: never

0 commit comments

Comments
 (0)