mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-11 17:41:26 -06:00
Merge pull request #39418 from a-tarasyuk/feat/25259-diagnostic
feat(25259): Better error report for equals instead of colon in object literals / change diagnostic message
This commit is contained in:
commit
64696225ab
@ -38266,7 +38266,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_When_following_property_names_in_an_object_literal_implies_a_destructuring_assignment);
|
||||
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);
|
||||
}
|
||||
|
||||
if (name.kind === SyntaxKind.PrivateIdentifier) {
|
||||
|
||||
@ -880,7 +880,7 @@
|
||||
"category": "Error",
|
||||
"code": 1308
|
||||
},
|
||||
"Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.": {
|
||||
"Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.": {
|
||||
"category": "Error",
|
||||
"code": 1312
|
||||
},
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
namespace ts.codefix {
|
||||
const fixId = "fixPropertyAssignment";
|
||||
const errorCodes = [
|
||||
Diagnostics.Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuring_assignment.code
|
||||
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.code
|
||||
];
|
||||
|
||||
registerCodeFix({
|
||||
|
||||
@ -11,7 +11,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(85,19): erro
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(85,26): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(111,14): error TS1312: Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.
|
||||
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(111,14): 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/compiler/shorthandPropertyAssignmentsInDestructuring.ts (12 errors) ====
|
||||
@ -153,7 +153,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(111,14): err
|
||||
(function() {
|
||||
let a = { s = 5 };
|
||||
~
|
||||
!!! error TS1312: Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.
|
||||
!!! 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.
|
||||
});
|
||||
|
||||
function foo({a = 4, b = { x: 5 }}) {
|
||||
|
||||
@ -11,7 +11,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(85,19):
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(85,26): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): error TS1312: Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.
|
||||
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): 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/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts (12 errors) ====
|
||||
@ -153,7 +153,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14):
|
||||
(function() {
|
||||
let a = { s = 5 };
|
||||
~
|
||||
!!! error TS1312: Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.
|
||||
!!! 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.
|
||||
});
|
||||
|
||||
function foo({a = 4, b = { x: 5 }}) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user