Missing properties in fresh object literals are known to be undefined

This commit is contained in:
Anders Hejlsberg 2017-10-24 13:27:55 -07:00
parent 228a885e49
commit b17e75b52b
2 changed files with 10 additions and 1 deletions

View file

@ -9604,6 +9604,15 @@ namespace ts {
}
return Ternary.False;
}
if (relation === subtypeRelation && target.flags & TypeFlags.FreshLiteral) {
const excessProperty = getUnmatchedProperty(target, source, /*requireOptionalProperties*/ true);
if (excessProperty) {
if (reportErrors) {
reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(excessProperty), typeToString(target));
}
return Ternary.False;
}
}
let result = Ternary.True;
const properties = getPropertiesOfObjectType(target);
for (const targetProp of properties) {

View file

@ -1273,7 +1273,7 @@ namespace ts {
return result;
}
function getDefaultValueForOption(option: CommandLineOption) {
function getDefaultValueForOption(option: CommandLineOption): {} {
switch (option.type) {
case "number":
return 1;