mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 03:09:39 -06:00
fix(error message): fixes issue in error message TS1355 (#62465)
This commit is contained in:
parent
e9bcbe6ef7
commit
233f392d67
@ -38003,7 +38003,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
const exprType = checkExpression(expression, checkMode);
|
||||
if (isConstTypeReference(type)) {
|
||||
if (!isValidConstAssertionArgument(expression)) {
|
||||
error(expression, Diagnostics.A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals);
|
||||
error(expression, Diagnostics.A_const_assertion_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals);
|
||||
}
|
||||
return getRegularTypeOfLiteralType(exprType);
|
||||
}
|
||||
|
||||
@ -1155,7 +1155,7 @@
|
||||
"category": "Error",
|
||||
"code": 1354
|
||||
},
|
||||
"A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.": {
|
||||
"A 'const' assertion can only be applied to references to enum members, or string, number, boolean, array, or object literals.": {
|
||||
"category": "Error",
|
||||
"code": 1355
|
||||
},
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
constAssertions.ts(44,32): error TS2540: Cannot assign to 'x' because it is a read-only property.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
constAssertions.ts(118,3): error TS2322: Type '3' is not assignable to type '2'.
|
||||
|
||||
|
||||
@ -70,13 +70,13 @@ constAssertions.ts(118,3): error TS2322: Type '3' is not assignable to type '2'.
|
||||
|
||||
let e1 = v1 as const; // Error
|
||||
~~
|
||||
!!! error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
|
||||
!!! error TS1355: A 'const' assertion can only be applied to references to enum members, or string, number, boolean, array, or object literals.
|
||||
let e2 = (true ? 1 : 0) as const; // Error
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
|
||||
!!! error TS1355: A 'const' assertion can only be applied to references to enum members, or string, number, boolean, array, or object literals.
|
||||
let e3 = id(1) as const; // Error
|
||||
~~~~~
|
||||
!!! error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
|
||||
!!! error TS1355: A 'const' assertion can only be applied to references to enum members, or string, number, boolean, array, or object literals.
|
||||
|
||||
let t1 = 'foo' as const;
|
||||
let t2 = 'bar' as const;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
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.
|
||||
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.
|
||||
|
||||
|
||||
==== constantEnumAssert.ts (1 errors) ====
|
||||
@ -52,5 +52,5 @@ constantEnumAssert.ts(49,20): error TS1355: A 'const' assertions can only be app
|
||||
|
||||
const foo12 = { a: E5.a as const }
|
||||
~~~~
|
||||
!!! error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
|
||||
!!! error TS1355: A 'const' assertion can only be applied to references to enum members, or string, number, boolean, array, or object literals.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user