From 7247d8e33a618650e256d43107b994b24b2bb84e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 25 May 2018 10:03:42 -0700 Subject: [PATCH] T extends unknown ? X : Y should eagerly resolve to X --- src/compiler/checker.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d1ede654a3d..abd39e46362 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8984,6 +8984,9 @@ namespace ts { if (checkType === wildcardType || extendsType === wildcardType) { return wildcardType; } + if (extendsType === getTopType()) { + return instantiateType(root.trueType, mapper); + } // If this is a distributive conditional type and the check type is generic we need to defer // resolution of the conditional type such that a later instantiation will properly distribute // over union types.