mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
fix(47056): report errors for all properties with errors (#47057)
This commit is contained in:
@@ -43089,7 +43089,7 @@ namespace ts {
|
||||
if (prop.kind === SyntaxKind.ShorthandPropertyAssignment && !inDestructuring && prop.objectAssignmentInitializer) {
|
||||
// having objectAssignmentInitializer is only valid in ObjectAssignmentPattern
|
||||
// outside of destructuring it is a syntax error
|
||||
return grammarErrorOnNode(prop.equalsToken!, Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern);
|
||||
grammarErrorOnNode(prop.equalsToken!, Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern);
|
||||
}
|
||||
|
||||
if (name.kind === SyntaxKind.PrivateIdentifier) {
|
||||
|
||||
@@ -74,9 +74,12 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(39,46)
|
||||
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(42,16): error TS2380: The return type of a 'get' accessor must be assignable to its 'set' accessor type
|
||||
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,22): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(44,16): error TS2380: The return type of a 'get' accessor must be assignable to its 'set' accessor type
|
||||
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(48,7): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.
|
||||
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(49,7): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.
|
||||
tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(50,5): error TS18016: Private identifiers are not allowed outside class bodies.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts (76 errors) ====
|
||||
==== tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts (79 errors) ====
|
||||
// Multiple properties with the same name
|
||||
var e1 = { a: 0, a: 0 };
|
||||
~
|
||||
@@ -273,4 +276,17 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(44,16)
|
||||
var g3 = { get a(): number { return undefined; }, set a(n: string) { } };
|
||||
~
|
||||
!!! error TS2380: The return type of a 'get' accessor must be assignable to its 'set' accessor type
|
||||
|
||||
// did you mean colon errors
|
||||
var h1 = {
|
||||
x = 1,
|
||||
~
|
||||
!!! error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.
|
||||
y = 2,
|
||||
~
|
||||
!!! error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.
|
||||
#z: 3
|
||||
~~
|
||||
!!! error TS18016: Private identifiers are not allowed outside class bodies.
|
||||
}
|
||||
|
||||
@@ -43,6 +43,13 @@ var f17 = { a: 0, get b() { return 1; }, get a() { return 0; } };
|
||||
var g1 = { get a(): number { return 4; }, set a(n: string) { } };
|
||||
var g2 = { get a() { return 4; }, set a(n: string) { } };
|
||||
var g3 = { get a(): number { return undefined; }, set a(n: string) { } };
|
||||
|
||||
// did you mean colon errors
|
||||
var h1 = {
|
||||
x = 1,
|
||||
y = 2,
|
||||
#z: 3
|
||||
}
|
||||
|
||||
|
||||
//// [objectLiteralErrors.js]
|
||||
@@ -88,3 +95,9 @@ var f17 = { a: 0, get b() { return 1; }, get a() { return 0; } };
|
||||
var g1 = { get a() { return 4; }, set a(n) { } };
|
||||
var g2 = { get a() { return 4; }, set a(n) { } };
|
||||
var g3 = { get a() { return undefined; }, set a(n) { } };
|
||||
// did you mean colon errors
|
||||
var h1 = {
|
||||
x: x,
|
||||
y: y,
|
||||
: 3
|
||||
};
|
||||
|
||||
@@ -203,3 +203,17 @@ var g3 = { get a(): number { return undefined; }, set a(n: string) { } };
|
||||
>a : Symbol(a, Decl(objectLiteralErrors.ts, 43, 10), Decl(objectLiteralErrors.ts, 43, 49))
|
||||
>n : Symbol(n, Decl(objectLiteralErrors.ts, 43, 56))
|
||||
|
||||
// did you mean colon errors
|
||||
var h1 = {
|
||||
>h1 : Symbol(h1, Decl(objectLiteralErrors.ts, 46, 3))
|
||||
|
||||
x = 1,
|
||||
>x : Symbol(x, Decl(objectLiteralErrors.ts, 46, 10))
|
||||
|
||||
y = 2,
|
||||
>y : Symbol(y, Decl(objectLiteralErrors.ts, 47, 10))
|
||||
|
||||
#z: 3
|
||||
>#z : Symbol(#z, Decl(objectLiteralErrors.ts, 48, 10))
|
||||
}
|
||||
|
||||
|
||||
@@ -318,3 +318,21 @@ var g3 = { get a(): number { return undefined; }, set a(n: string) { } };
|
||||
>a : number
|
||||
>n : string
|
||||
|
||||
// did you mean colon errors
|
||||
var h1 = {
|
||||
>h1 : { x: number; y: number; }
|
||||
>{ x = 1, y = 2, #z: 3} : { x: number; y: number; }
|
||||
|
||||
x = 1,
|
||||
>x : any
|
||||
>1 : 1
|
||||
|
||||
y = 2,
|
||||
>y : any
|
||||
>2 : 2
|
||||
|
||||
#z: 3
|
||||
>#z : number
|
||||
>3 : 3
|
||||
}
|
||||
|
||||
|
||||
@@ -44,3 +44,10 @@ var f17 = { a: 0, get b() { return 1; }, get a() { return 0; } };
|
||||
var g1 = { get a(): number { return 4; }, set a(n: string) { } };
|
||||
var g2 = { get a() { return 4; }, set a(n: string) { } };
|
||||
var g3 = { get a(): number { return undefined; }, set a(n: string) { } };
|
||||
|
||||
// did you mean colon errors
|
||||
var h1 = {
|
||||
x = 1,
|
||||
y = 2,
|
||||
#z: 3
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user