Skip to content

Commit 0ba250d

Browse files
saigeethakandepallicherukuruSai Geetha
andauthored
Updated error message for TS1031 (microsoft#40889)
Co-authored-by: Sai Geetha <[email protected]>
1 parent da86332 commit 0ba250d

12 files changed

+23
-23
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38687,7 +38687,7 @@ namespace ts {
3868738687
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "async");
3868838688
}
3868938689
else if (isClassLike(node.parent)) {
38690-
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export");
38690+
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export");
3869138691
}
3869238692
else if (node.kind === SyntaxKind.Parameter) {
3869338693
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export");
@@ -38710,7 +38710,7 @@ namespace ts {
3871038710
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
3871138711
}
3871238712
else if (isClassLike(node.parent) && !isPropertyDeclaration(node)) {
38713-
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare");
38713+
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare");
3871438714
}
3871538715
else if (node.kind === SyntaxKind.Parameter) {
3871638716
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"category": "Error",
100100
"code": 1030
101101
},
102-
"'{0}' modifier cannot appear on a class element.": {
102+
"'{0}' modifier cannot appear on class elements of this kind.": {
103103
"category": "Error",
104104
"code": 1031
105105
},
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/compiler/classExpressionPropertyModifiers.ts(2,36): error TS1039: Initializers are not allowed in ambient contexts.
2-
tests/cases/compiler/classExpressionPropertyModifiers.ts(3,5): error TS1031: 'export' modifier cannot appear on a class element.
2+
tests/cases/compiler/classExpressionPropertyModifiers.ts(3,5): error TS1031: 'export' modifier cannot appear on class elements of this kind.
33

44

55
==== tests/cases/compiler/classExpressionPropertyModifiers.ts (2 errors) ====
@@ -9,6 +9,6 @@ tests/cases/compiler/classExpressionPropertyModifiers.ts(3,5): error TS1031: 'ex
99
!!! error TS1039: Initializers are not allowed in ambient contexts.
1010
export foo = 1;
1111
~~~~~~
12-
!!! error TS1031: 'export' modifier cannot appear on a class element.
12+
!!! error TS1031: 'export' modifier cannot appear on class elements of this kind.
1313
}
1414

tests/baselines/reference/derivedUninitializedPropertyDeclaration.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(12,21): error TS1255: A definite assignment assertion '!' is not permitted in this context.
2-
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(15,5): error TS1031: 'declare' modifier cannot appear on a class element.
2+
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(15,5): error TS1031: 'declare' modifier cannot appear on class elements of this kind.
33
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(15,17): error TS1183: An implementation cannot be declared in ambient contexts.
44
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(17,24): error TS1039: Initializers are not allowed in ambient contexts.
55
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(24,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor.
@@ -25,7 +25,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedP
2525
class BOther extends A {
2626
declare m() { return 2 } // not allowed on methods
2727
~~~~~~~
28-
!!! error TS1031: 'declare' modifier cannot appear on a class element.
28+
!!! error TS1031: 'declare' modifier cannot appear on class elements of this kind.
2929
~
3030
!!! error TS1183: An implementation cannot be declared in ambient contexts.
3131
declare nonce: any; // ok, even though it's not in the base
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/compiler/illegalModifiersOnClassElements.ts(2,19): error TS1039: Initializers are not allowed in ambient contexts.
2-
tests/cases/compiler/illegalModifiersOnClassElements.ts(3,5): error TS1031: 'export' modifier cannot appear on a class element.
2+
tests/cases/compiler/illegalModifiersOnClassElements.ts(3,5): error TS1031: 'export' modifier cannot appear on class elements of this kind.
33

44

55
==== tests/cases/compiler/illegalModifiersOnClassElements.ts (2 errors) ====
@@ -9,5 +9,5 @@ tests/cases/compiler/illegalModifiersOnClassElements.ts(3,5): error TS1031: 'exp
99
!!! error TS1039: Initializers are not allowed in ambient contexts.
1010
export bar = 1;
1111
~~~~~~
12-
!!! error TS1031: 'export' modifier cannot appear on a class element.
12+
!!! error TS1031: 'export' modifier cannot appear on class elements of this kind.
1313
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration3.ts(2,3): error TS1031: 'export' modifier cannot appear on a class element.
1+
tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration3.ts(2,3): error TS1031: 'export' modifier cannot appear on class elements of this kind.
22

33

44
==== tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration3.ts (1 errors) ====
55
class C {
66
export constructor() { }
77
~~~~~~
8-
!!! error TS1031: 'export' modifier cannot appear on a class element.
8+
!!! error TS1031: 'export' modifier cannot appear on class elements of this kind.
99
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts(2,3): error TS1031: 'declare' modifier cannot appear on a class element.
1+
tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts(2,3): error TS1031: 'declare' modifier cannot appear on class elements of this kind.
22

33

44
==== tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts (1 errors) ====
55
class C {
66
declare constructor() { }
77
~~~~~~~
8-
!!! error TS1031: 'declare' modifier cannot appear on a class element.
8+
!!! error TS1031: 'declare' modifier cannot appear on class elements of this kind.
99
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration10.ts(2,5): error TS1031: 'export' modifier cannot appear on a class element.
1+
tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration10.ts(2,5): error TS1031: 'export' modifier cannot appear on class elements of this kind.
22
tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration10.ts(2,16): error TS2378: A 'get' accessor must return a value.
33

44

55
==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration10.ts (2 errors) ====
66
class C {
77
export get Foo() { }
88
~~~~~~
9-
!!! error TS1031: 'export' modifier cannot appear on a class element.
9+
!!! error TS1031: 'export' modifier cannot appear on class elements of this kind.
1010
~~~
1111
!!! error TS2378: A 'get' accessor must return a value.
1212
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element.
1+
tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts(2,5): error TS1031: 'declare' modifier cannot appear on class elements of this kind.
22
tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts(2,17): error TS2378: A 'get' accessor must return a value.
33

44

55
==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts (2 errors) ====
66
class C {
77
declare get Foo() { }
88
~~~~~~~
9-
!!! error TS1031: 'declare' modifier cannot appear on a class element.
9+
!!! error TS1031: 'declare' modifier cannot appear on class elements of this kind.
1010
~~~
1111
!!! error TS2378: A 'get' accessor must return a value.
1212
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration4.ts(2,5): error TS1031: 'export' modifier cannot appear on a class element.
1+
tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration4.ts(2,5): error TS1031: 'export' modifier cannot appear on class elements of this kind.
22

33

44
==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration4.ts (1 errors) ====
55
class C {
66
export Foo() { }
77
~~~~~~
8-
!!! error TS1031: 'export' modifier cannot appear on a class element.
8+
!!! error TS1031: 'export' modifier cannot appear on class elements of this kind.
99
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element.
1+
tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,5): error TS1031: 'declare' modifier cannot appear on class elements of this kind.
22
tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,19): error TS1183: An implementation cannot be declared in ambient contexts.
33

44

55
==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (2 errors) ====
66
class C {
77
declare Foo() { }
88
~~~~~~~
9-
!!! error TS1031: 'declare' modifier cannot appear on a class element.
9+
!!! error TS1031: 'declare' modifier cannot appear on class elements of this kind.
1010
~
1111
!!! error TS1183: An implementation cannot be declared in ambient contexts.
1212
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration4.ts(2,3): error TS1031: 'export' modifier cannot appear on a class element.
1+
tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration4.ts(2,3): error TS1031: 'export' modifier cannot appear on class elements of this kind.
22

33

44
==== tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration4.ts (1 errors) ====
55
class C {
66
export Foo;
77
~~~~~~
8-
!!! error TS1031: 'export' modifier cannot appear on a class element.
8+
!!! error TS1031: 'export' modifier cannot appear on class elements of this kind.
99
}

0 commit comments

Comments
 (0)