mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 07:13:45 -05:00
Merge pull request #4552 from Microsoft/bettErrErrorsForObjectLiteralExcessProperties
Better error spans for object literal excess properties
This commit is contained in:
@@ -4548,7 +4548,7 @@ namespace ts {
|
||||
* @param target The right-hand-side of the relation.
|
||||
* @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'.
|
||||
* Used as both to determine which checks are performed and as a cache of previously computed results.
|
||||
* @param errorNode The node upon which all errors will be reported, if defined.
|
||||
* @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used.
|
||||
* @param headMessage If the error chain should be prepended by a head message, then headMessage will be used.
|
||||
* @param containingMessageChain A chain of errors to prepend any new errors found.
|
||||
*/
|
||||
@@ -4767,7 +4767,13 @@ namespace ts {
|
||||
for (let prop of getPropertiesOfObjectType(source)) {
|
||||
if (!isKnownProperty(target, prop.name)) {
|
||||
if (reportErrors) {
|
||||
reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target));
|
||||
// We know *exactly* where things went wrong when comparing the types.
|
||||
// Use this property as the error node as this will be more helpful in
|
||||
// reasoning about what went wrong.
|
||||
errorNode = prop.valueDeclaration
|
||||
reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1,
|
||||
symbolToString(prop),
|
||||
typeToString(target));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user