Skip to content

Commit 15e1904

Browse files
committed
Adjust error message
1 parent b12315f commit 15e1904

File tree

4 files changed

+100
-100
lines changed

4 files changed

+100
-100
lines changed

src/compiler/checker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -30560,7 +30560,7 @@ namespace ts {
3056030560
if (node.kind === SyntaxKind.TypeAssertionExpression) {
3056130561
const file = getSourceFileOfNode(node);
3056230562
if (file && fileExtensionIsOneOf(file.fileName, [Extension.Cts, Extension.Mts])) {
30563-
grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_this_extension_Use_an_as_expression_instead);
30563+
grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead);
3056430564
}
3056530565
}
3056630566
return checkAssertionWorker(node, node.type, node.expression);
@@ -41806,7 +41806,7 @@ namespace ts {
4180641806

4180741807
if (node.typeParameters && !(length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) {
4180841808
if (file && fileExtensionIsOneOf(file.fileName, [Extension.Mts, Extension.Cts])) {
41809-
grammarErrorOnNode(node.typeParameters[0], Diagnostics.This_syntax_is_reserved_in_files_with_this_extension_Add_a_trailing_comma_or_explicit_constraint);
41809+
grammarErrorOnNode(node.typeParameters[0], Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint);
4181041810
}
4181141811
}
4181241812

src/compiler/diagnosticMessages.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5888,11 +5888,11 @@
58885888
"category": "Error",
58895889
"code": 7058
58905890
},
5891-
"This syntax is reserved in files with this extension. Use an `as` expression instead.": {
5891+
"This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.": {
58925892
"category": "Error",
58935893
"code": 7059
58945894
},
5895-
"This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.": {
5895+
"This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.": {
58965896
"category": "Error",
58975897
"code": 7060
58985898
},

tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt

+48-48
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
tests/cases/conformance/node/index.cts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
2-
tests/cases/conformance/node/index.cts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
3-
tests/cases/conformance/node/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
4-
tests/cases/conformance/node/index.mts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
5-
tests/cases/conformance/node/index.mts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
6-
tests/cases/conformance/node/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
7-
tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
8-
tests/cases/conformance/node/subfolder/index.cts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
9-
tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
10-
tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
11-
tests/cases/conformance/node/subfolder/index.mts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
12-
tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
13-
tests/cases/conformance/node/subfolder2/another/index.cts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
14-
tests/cases/conformance/node/subfolder2/another/index.cts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
15-
tests/cases/conformance/node/subfolder2/another/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
16-
tests/cases/conformance/node/subfolder2/another/index.mts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
17-
tests/cases/conformance/node/subfolder2/another/index.mts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
18-
tests/cases/conformance/node/subfolder2/another/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
19-
tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
20-
tests/cases/conformance/node/subfolder2/index.cts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
21-
tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
22-
tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
23-
tests/cases/conformance/node/subfolder2/index.mts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
24-
tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
1+
tests/cases/conformance/node/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
2+
tests/cases/conformance/node/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
3+
tests/cases/conformance/node/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
4+
tests/cases/conformance/node/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
5+
tests/cases/conformance/node/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
6+
tests/cases/conformance/node/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
7+
tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
8+
tests/cases/conformance/node/subfolder/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
9+
tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
10+
tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
11+
tests/cases/conformance/node/subfolder/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
12+
tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
13+
tests/cases/conformance/node/subfolder2/another/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
14+
tests/cases/conformance/node/subfolder2/another/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
15+
tests/cases/conformance/node/subfolder2/another/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
16+
tests/cases/conformance/node/subfolder2/another/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
17+
tests/cases/conformance/node/subfolder2/another/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
18+
tests/cases/conformance/node/subfolder2/another/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
19+
tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
20+
tests/cases/conformance/node/subfolder2/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
21+
tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
22+
tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
23+
tests/cases/conformance/node/subfolder2/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
24+
tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
2525

2626

2727
==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ====
@@ -32,21 +32,21 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt
3232
// cjs format file
3333
const x = <T>() => <T><any>(void 0);
3434
~
35-
!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
35+
!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
3636
~~~~~~~~~~~~~~~~
37-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
37+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
3838
~~~~~~~~~~~~~
39-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
39+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
4040
export {x};
4141
==== tests/cases/conformance/node/subfolder/index.mts (3 errors) ====
4242
// esm format file
4343
const x = <T>() => <T><any>(void 0);
4444
~
45-
!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
45+
!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
4646
~~~~~~~~~~~~~~~~
47-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
47+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
4848
~~~~~~~~~~~~~
49-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
49+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
5050
export {x};
5151
==== tests/cases/conformance/node/subfolder2/index.ts (0 errors) ====
5252
// cjs format file
@@ -56,21 +56,21 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt
5656
// cjs format file
5757
const x = <T>() => <T><any>(void 0);
5858
~
59-
!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
59+
!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
6060
~~~~~~~~~~~~~~~~
61-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
61+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
6262
~~~~~~~~~~~~~
63-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
63+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
6464
export {x};
6565
==== tests/cases/conformance/node/subfolder2/index.mts (3 errors) ====
6666
// esm format file
6767
const x = <T>() => <T><any>(void 0);
6868
~
69-
!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
69+
!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
7070
~~~~~~~~~~~~~~~~
71-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
71+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
7272
~~~~~~~~~~~~~
73-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
73+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
7474
export {x};
7575
==== tests/cases/conformance/node/subfolder2/another/index.ts (0 errors) ====
7676
// esm format file
@@ -80,41 +80,41 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt
8080
// esm format file
8181
const x = <T>() => <T><any>(void 0);
8282
~
83-
!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
83+
!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
8484
~~~~~~~~~~~~~~~~
85-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
85+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
8686
~~~~~~~~~~~~~
87-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
87+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
8888
export {x};
8989
==== tests/cases/conformance/node/subfolder2/another/index.cts (3 errors) ====
9090
// cjs format file
9191
const x = <T>() => <T><any>(void 0);
9292
~
93-
!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
93+
!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
9494
~~~~~~~~~~~~~~~~
95-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
95+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
9696
~~~~~~~~~~~~~
97-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
97+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
9898
export {x};
9999
==== tests/cases/conformance/node/index.mts (3 errors) ====
100100
// esm format file
101101
const x = <T>() => <T><any>(void 0);
102102
~
103-
!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
103+
!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
104104
~~~~~~~~~~~~~~~~
105-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
105+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
106106
~~~~~~~~~~~~~
107-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
107+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
108108
export {x};
109109
==== tests/cases/conformance/node/index.cts (3 errors) ====
110110
// cjs format file
111111
const x = <T>() => <T><any>(void 0);
112112
~
113-
!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.
113+
!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.
114114
~~~~~~~~~~~~~~~~
115-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
115+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
116116
~~~~~~~~~~~~~
117-
!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead.
117+
!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.
118118
export {x};
119119
==== tests/cases/conformance/node/index.ts (0 errors) ====
120120
// esm format file

0 commit comments

Comments
 (0)