@@ -4946,34 +4946,34 @@ namespace ts {
4946
4946
resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) {
4947
4947
return true;
4948
4948
}
4949
- return false;
4950
4949
}
4951
- if (type.flags & TypeFlags.UnionOrIntersection) {
4950
+ else if (type.flags & TypeFlags.UnionOrIntersection) {
4952
4951
for (let t of (<UnionOrIntersectionType>type).types) {
4953
4952
if (isKnownProperty(t, name)) {
4954
4953
return true;
4955
4954
}
4956
4955
}
4957
- return false;
4958
4956
}
4959
- return true ;
4957
+ return false ;
4960
4958
}
4961
4959
4962
4960
function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
4963
- for (let prop of getPropertiesOfObjectType(source)) {
4964
- if (!isKnownProperty(target, prop.name)) {
4965
- if (reportErrors) {
4966
- // We know *exactly* where things went wrong when comparing the types.
4967
- // Use this property as the error node as this will be more helpful in
4968
- // reasoning about what went wrong.
4969
- errorNode = prop.valueDeclaration;
4970
- reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1,
4971
- symbolToString(prop),
4972
- typeToString(target));
4961
+ if (someConstituentTypeHasKind(target, TypeFlags.ObjectType)) {
4962
+ for (let prop of getPropertiesOfObjectType(source)) {
4963
+ if (!isKnownProperty(target, prop.name)) {
4964
+ if (reportErrors) {
4965
+ // We know *exactly* where things went wrong when comparing the types.
4966
+ // Use this property as the error node as this will be more helpful in
4967
+ // reasoning about what went wrong.
4968
+ errorNode = prop.valueDeclaration;
4969
+ reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1,
4970
+ symbolToString(prop), typeToString(target));
4971
+ }
4972
+ return true;
4973
4973
}
4974
- return true;
4975
4974
}
4976
4975
}
4976
+ return false;
4977
4977
}
4978
4978
4979
4979
function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType): Ternary {
0 commit comments