@@ -16313,18 +16313,20 @@ namespace ts {
16313
16313
if (isJsxAttributes(errorNode) || isJsxOpeningLikeElement(errorNode) || isJsxOpeningLikeElement(errorNode.parent)) {
16314
16314
// JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal.
16315
16315
// However, using an object-literal error message will be very confusing to the users so we give different a message.
16316
- // TODO: Spelling suggestions for excess jsx attributes (needs new diagnostic messages)
16317
16316
if (prop.valueDeclaration && isJsxAttribute(prop.valueDeclaration) && getSourceFileOfNode(errorNode) === getSourceFileOfNode(prop.valueDeclaration.name)) {
16318
16317
// Note that extraneous children (as in `<NoChild>extra</NoChild>`) don't pass this check,
16319
16318
// since `children` is a SyntaxKind.PropertySignature instead of a SyntaxKind.JsxAttribute.
16320
16319
errorNode = prop.valueDeclaration.name;
16321
16320
}
16322
- reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget));
16321
+ const propName = symbolToString(prop);
16322
+ const suggestion = getSuggestionForNonexistentProperty(propName, errorTarget);
16323
+ if (suggestion) reportError(Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(errorTarget), suggestion);
16324
+ else reportError(Diagnostics.Property_0_does_not_exist_on_type_1, propName, typeToString(errorTarget));
16323
16325
}
16324
16326
else {
16325
16327
// use the property's value declaration if the property is assigned inside the literal itself
16326
16328
const objectLiteralDeclaration = source.symbol && firstOrUndefined(source.symbol.declarations);
16327
- let suggestion;
16329
+ let suggestion: string | undefined ;
16328
16330
if (prop.valueDeclaration && findAncestor(prop.valueDeclaration, d => d === objectLiteralDeclaration) && getSourceFileOfNode(objectLiteralDeclaration) === getSourceFileOfNode(errorNode)) {
16329
16331
const propDeclaration = prop.valueDeclaration as ObjectLiteralElementLike;
16330
16332
Debug.assertNode(propDeclaration, isObjectLiteralElementLike);
0 commit comments