Skip to content

Commit 77ed56b

Browse files
committed
fix(error message): fixes issue in error message TS1355
1 parent e9bcbe6 commit 77ed56b

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38003,7 +38003,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3800338003
const exprType = checkExpression(expression, checkMode);
3800438004
if (isConstTypeReference(type)) {
3800538005
if (!isValidConstAssertionArgument(expression)) {
38006-
error(expression, Diagnostics.A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals);
38006+
error(expression, Diagnostics.A_const_assertion_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals);
3800738007
}
3800838008
return getRegularTypeOfLiteralType(exprType);
3800938009
}

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@
11551155
"category": "Error",
11561156
"code": 1354
11571157
},
1158-
"A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.": {
1158+
"A 'const' assertion can only be applied to references to enum members, or string, number, boolean, array, or object literals.": {
11591159
"category": "Error",
11601160
"code": 1355
11611161
},

tests/baselines/reference/constAssertions.errors.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
constAssertions.ts(44,32): error TS2540: Cannot assign to 'x' because it is a read-only property.
2-
constAssertions.ts(61,10): error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
3-
constAssertions.ts(62,10): error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
4-
constAssertions.ts(63,10): error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
2+
constAssertions.ts(61,10): error TS1355: A 'const' assertion can only be applied to references to enum members, or string, number, boolean, array, or object literals.
3+
constAssertions.ts(62,10): error TS1355: A 'const' assertion can only be applied to references to enum members, or string, number, boolean, array, or object literals.
4+
constAssertions.ts(63,10): error TS1355: A 'const' assertion can only be applied to references to enum members, or string, number, boolean, array, or object literals.
55
constAssertions.ts(118,3): error TS2322: Type '3' is not assignable to type '2'.
66

77

@@ -70,13 +70,13 @@ constAssertions.ts(118,3): error TS2322: Type '3' is not assignable to type '2'.
7070

7171
let e1 = v1 as const; // Error
7272
~~
73-
!!! error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
73+
!!! error TS1355: A 'const' assertion can only be applied to references to enum members, or string, number, boolean, array, or object literals.
7474
let e2 = (true ? 1 : 0) as const; // Error
7575
~~~~~~~~~~~~~~
76-
!!! error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
76+
!!! error TS1355: A 'const' assertion can only be applied to references to enum members, or string, number, boolean, array, or object literals.
7777
let e3 = id(1) as const; // Error
7878
~~~~~
79-
!!! error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
79+
!!! error TS1355: A 'const' assertion can only be applied to references to enum members, or string, number, boolean, array, or object literals.
8080

8181
let t1 = 'foo' as const;
8282
let t2 = 'bar' as const;

tests/baselines/reference/constantEnumAssert.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
constantEnumAssert.ts(49,20): error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
1+
constantEnumAssert.ts(49,20): error TS1355: A 'const' assertion can only be applied to references to enum members, or string, number, boolean, array, or object literals.
22

33

44
==== constantEnumAssert.ts (1 errors) ====
@@ -52,5 +52,5 @@ constantEnumAssert.ts(49,20): error TS1355: A 'const' assertions can only be app
5252

5353
const foo12 = { a: E5.a as const }
5454
~~~~
55-
!!! error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
55+
!!! error TS1355: A 'const' assertion can only be applied to references to enum members, or string, number, boolean, array, or object literals.
5656

0 commit comments

Comments
 (0)