Merge pull request #33477 from Nathan-Fenner/error-on-extra-jsx-prop

report error on extraneous JSX prop instead of element name
This commit is contained in:
Daniel Rosenwasser
2019-09-23 15:26:57 -07:00
committed by GitHub
18 changed files with 73 additions and 68 deletions

View File

@@ -13041,6 +13041,11 @@ namespace ts {
// JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal.
// However, using an object-literal error message will be very confusing to the users so we give different a message.
// TODO: Spelling suggestions for excess jsx attributes (needs new diagnostic messages)
if (prop.valueDeclaration && isJsxAttribute(prop.valueDeclaration)) {
// Note that extraneous children (as in `<NoChild>extra</NoChild>`) don't pass this check,
// since `children` is a SyntaxKind.PropertySignature instead of a SyntaxKind.JsxAttribute.
errorNode = prop.valueDeclaration.name;
}
reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget));
}
else {