fix(42339): skip return if spread type is wrong

This commit is contained in:
Oleksandr T
2021-02-21 12:05:26 +02:00
parent c7fa6e0154
commit 74e3ad9735
6 changed files with 176 additions and 8 deletions

View File

@@ -25318,15 +25318,20 @@ namespace ts {
hasComputedNumberProperty = false;
}
const type = getReducedType(checkExpression(memberDecl.expression));
if (!isValidSpreadType(type)) {
if (isValidSpreadType(type)) {
if (allPropertiesTable) {
checkSpreadPropOverrides(type, allPropertiesTable, memberDecl);
}
offset = propertiesArray.length;
if (spread === errorType) {
continue;
}
spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext);
}
else {
error(memberDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types);
return errorType;
spread = errorType;
}
if (allPropertiesTable) {
checkSpreadPropOverrides(type, allPropertiesTable, memberDecl);
}
spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext);
offset = propertiesArray.length;
continue;
}
else {
@@ -25375,6 +25380,10 @@ namespace ts {
}
}
if (spread === errorType) {
return errorType;
}
if (spread !== emptyObjectType) {
if (propertiesArray.length > 0) {
spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);