Unwrap substitutions on conditional check types before comparing them (#43888)

This commit is contained in:
Wesley Wigham
2021-05-05 13:33:45 -07:00
committed by GitHub
parent 84da19efc8
commit b83148fe64
5 changed files with 33 additions and 1 deletions

View File

@@ -15022,7 +15022,7 @@ namespace ts {
// purposes of resolution. This means such types aren't subject to the instatiation depth limiter.
while (true) {
const isUnwrapped = isTypicalNondistributiveConditional(root);
const checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.checkType), mapper);
const checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
const checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
const extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
if (checkType === wildcardType || extendsType === wildcardType) {

View File

@@ -0,0 +1,7 @@
//// [curiousNestedConditionalEvaluationResult.ts]
// regression test for #43123
type Hmm = [0] extends [infer T, any?] ?
[T, [0] extends [T] ? true : false]
: never
//// [curiousNestedConditionalEvaluationResult.js]

View File

@@ -0,0 +1,11 @@
=== tests/cases/compiler/curiousNestedConditionalEvaluationResult.ts ===
// regression test for #43123
type Hmm = [0] extends [infer T, any?] ?
>Hmm : Symbol(Hmm, Decl(curiousNestedConditionalEvaluationResult.ts, 0, 0))
>T : Symbol(T, Decl(curiousNestedConditionalEvaluationResult.ts, 1, 29))
[T, [0] extends [T] ? true : false]
>T : Symbol(T, Decl(curiousNestedConditionalEvaluationResult.ts, 1, 29))
>T : Symbol(T, Decl(curiousNestedConditionalEvaluationResult.ts, 1, 29))
: never

View File

@@ -0,0 +1,10 @@
=== tests/cases/compiler/curiousNestedConditionalEvaluationResult.ts ===
// regression test for #43123
type Hmm = [0] extends [infer T, any?] ?
>Hmm : [0, true]
[T, [0] extends [T] ? true : false]
>true : true
>false : false
: never

View File

@@ -0,0 +1,4 @@
// regression test for #43123
type Hmm = [0] extends [infer T, any?] ?
[T, [0] extends [T] ? true : false]
: never