From 7a19b66cc0ae44456b7c62a4c84b718d35777a7c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 1 Mar 2018 16:01:32 -0800 Subject: [PATCH] Don't propagate 'never' types in type inference --- src/compiler/checker.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ae91d887781..1931661bf5f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11525,10 +11525,10 @@ namespace ts { if (!couldContainTypeVariables(target)) { return; } - if (source.flags & (TypeFlags.Any | TypeFlags.Never) && source !== silentNeverType) { - // We are inferring from 'any' or 'never'. We want to infer this type for every type parameter - // referenced in the target type, so we record the propagation type and infer from the target - // to itself. Then, as we find candidates we substitute the propagation type. + if (source.flags & TypeFlags.Any) { + // We are inferring from an 'any' type. We want to infer this type for every type parameter + // referenced in the target type, so we record it as the propagation type and infer from the + // target to itself. Then, as we find candidates we substitute the propagation type. const savePropagationType = propagationType; propagationType = source; inferFromTypes(target, target);