Skip to content

Commit 587252c

Browse files
authored
feat(40674): make error messages more consistent (#40675)
1 parent 0310b53 commit 587252c

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39487,7 +39487,7 @@ namespace ts {
3948739487
if (node.exclamationToken && (node.parent.parent.kind !== SyntaxKind.VariableStatement || !node.type || node.initializer || node.flags & NodeFlags.Ambient)) {
3948839488
const message = node.initializer
3948939489
? Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
39490-
: Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation;
39490+
: Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations;
3949139491
return grammarErrorOnNode(node.exclamationToken, message);
3949239492
}
3949339493

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -851,10 +851,6 @@
851851
"category": "Error",
852852
"code": 1257
853853
},
854-
"Definite assignment assertions can only be used along with a type annotation.": {
855-
"category": "Error",
856-
"code": 1258
857-
},
858854
"Module '{0}' can only be default-imported using the '{1}' flag": {
859855
"category": "Error",
860856
"code": 1259

tests/baselines/reference/definiteAssignmentAssertions.errors.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(23,5): error
66
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(23,6): error TS1264: Declarations with definite assignment assertions must also have type annotations.
77
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(29,6): error TS1255: A definite assignment assertion '!' is not permitted in this context.
88
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(35,15): error TS1255: A definite assignment assertion '!' is not permitted in this context.
9-
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(69,10): error TS1258: Definite assignment assertions can only be used along with a type annotation.
9+
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(69,10): error TS1264: Declarations with definite assignment assertions must also have type annotations.
1010
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(70,10): error TS1263: Declarations with initializers cannot also have definite assignment assertions.
1111
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(71,10): error TS1263: Declarations with initializers cannot also have definite assignment assertions.
12-
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(76,15): error TS1258: Definite assignment assertions can only be used along with a type annotation.
13-
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(77,15): error TS1258: Definite assignment assertions can only be used along with a type annotation.
12+
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(76,15): error TS1264: Declarations with definite assignment assertions must also have type annotations.
13+
tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(77,15): error TS1264: Declarations with definite assignment assertions must also have type annotations.
1414

1515

1616
==== tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts (13 errors) ====
@@ -100,7 +100,7 @@ tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(77,15): erro
100100
function f4() {
101101
let a!;
102102
~
103-
!!! error TS1258: Definite assignment assertions can only be used along with a type annotation.
103+
!!! error TS1264: Declarations with definite assignment assertions must also have type annotations.
104104
let b! = 1;
105105
~
106106
!!! error TS1263: Declarations with initializers cannot also have definite assignment assertions.
@@ -113,8 +113,8 @@ tests/cases/conformance/controlFlow/definiteAssignmentAssertions.ts(77,15): erro
113113

114114
declare let v1!: number;
115115
~
116-
!!! error TS1258: Definite assignment assertions can only be used along with a type annotation.
116+
!!! error TS1264: Declarations with definite assignment assertions must also have type annotations.
117117
declare var v2!: number;
118118
~
119-
!!! error TS1258: Definite assignment assertions can only be used along with a type annotation.
119+
!!! error TS1264: Declarations with definite assignment assertions must also have type annotations.
120120

0 commit comments

Comments
 (0)