Skip to content

Commit 4b813e3

Browse files
committed
Simplify non-inferrable property check to rely on propagation
1 parent 411e714 commit 4b813e3

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14502,16 +14502,10 @@ namespace ts {
1450214502
}
1450314503

1450414504
function createReverseMappedType(source: Type, target: MappedType, constraint: IndexType) {
14505-
const properties = getPropertiesOfType(source);
14506-
if (properties.length === 0 && !getIndexInfoOfType(source, IndexKind.String)) {
14507-
return undefined;
14508-
}
1450914505
// If any property contains context sensitive functions that have been skipped, the source type
1451014506
// is incomplete and we can't infer a meaningful input type.
14511-
for (const prop of properties) {
14512-
if (getObjectFlags(getTypeOfSymbol(prop)) & ObjectFlags.NonInferrableType) {
14513-
return undefined;
14514-
}
14507+
if (getObjectFlags(source) & ObjectFlags.NonInferrableType || getPropertiesOfType(source).length === 0 && !getIndexInfoOfType(source, IndexKind.String)) {
14508+
return undefined;
1451514509
}
1451614510
// For arrays and tuples we infer new arrays and tuples where the reverse mapping has been
1451714511
// applied to the element type(s).

0 commit comments

Comments
 (0)