From 4b813e310c3e5e7b758b85eada14ba45b898233e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 10 Apr 2019 17:05:07 -1000 Subject: [PATCH] Simplify non-inferrable property check to rely on propagation --- src/compiler/checker.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a1e21e010fb..e3fda9e6e42 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14502,16 +14502,10 @@ namespace ts { } function createReverseMappedType(source: Type, target: MappedType, constraint: IndexType) { - const properties = getPropertiesOfType(source); - if (properties.length === 0 && !getIndexInfoOfType(source, IndexKind.String)) { - return undefined; - } // If any property contains context sensitive functions that have been skipped, the source type // is incomplete and we can't infer a meaningful input type. - for (const prop of properties) { - if (getObjectFlags(getTypeOfSymbol(prop)) & ObjectFlags.NonInferrableType) { - return undefined; - } + if (getObjectFlags(source) & ObjectFlags.NonInferrableType || getPropertiesOfType(source).length === 0 && !getIndexInfoOfType(source, IndexKind.String)) { + return undefined; } // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been // applied to the element type(s).