mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Do not allow freshness to move errors out of the current file, ensure json documents are deeply unfreshened and fully widened (#35048)
This commit is contained in:
@@ -7310,11 +7310,7 @@ namespace ts {
|
||||
if (!declaration.statements.length) {
|
||||
return emptyObjectType;
|
||||
}
|
||||
const type = getWidenedLiteralType(checkExpression(declaration.statements[0].expression));
|
||||
if (type.flags & TypeFlags.Object) {
|
||||
return getRegularTypeOfObjectLiteral(type);
|
||||
}
|
||||
return type;
|
||||
return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
|
||||
}
|
||||
|
||||
// Handle variable, parameter or property
|
||||
@@ -14807,7 +14803,7 @@ 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)) {
|
||||
if (prop.valueDeclaration && isJsxAttribute(prop.valueDeclaration) && getSourceFileOfNode(errorNode) === getSourceFileOfNode(prop.valueDeclaration.name)) {
|
||||
// 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;
|
||||
@@ -14818,7 +14814,7 @@ namespace ts {
|
||||
// use the property's value declaration if the property is assigned inside the literal itself
|
||||
const objectLiteralDeclaration = source.symbol && firstOrUndefined(source.symbol.declarations);
|
||||
let suggestion;
|
||||
if (prop.valueDeclaration && findAncestor(prop.valueDeclaration, d => d === objectLiteralDeclaration)) {
|
||||
if (prop.valueDeclaration && findAncestor(prop.valueDeclaration, d => d === objectLiteralDeclaration) && getSourceFileOfNode(objectLiteralDeclaration) === getSourceFileOfNode(errorNode)) {
|
||||
const propDeclaration = prop.valueDeclaration as ObjectLiteralElementLike;
|
||||
Debug.assertNode(propDeclaration, isObjectLiteralElementLike);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user