Skip to content

Commit 0652664

Browse files
Fix error message incorrectly referencing 'asserts' instead of 'assert'. (microsoft#61066)
1 parent fed7a7f commit 0652664

7 files changed

+32
-32
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48156,7 +48156,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4815648156
}
4815748157

4815848158
if (moduleKind === ModuleKind.NodeNext && !isImportAttributes) {
48159-
return grammarErrorOnFirstToken(node, Diagnostics.Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_asserts);
48159+
return grammarErrorOnFirstToken(node, Diagnostics.Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_assert);
4816048160
}
4816148161

4816248162
if (declaration.moduleSpecifier && getEmitSyntaxForModuleSpecifierExpression(declaration.moduleSpecifier) === ModuleKind.CommonJS) {

src/compiler/diagnosticMessages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3983,7 +3983,7 @@
39833983
"category": "Error",
39843984
"code": 2879
39853985
},
3986-
"Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.": {
3986+
"Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.": {
39873987
"category": "Error",
39883988
"code": 2880
39893989
},
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
mod.mts(1,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
1+
mod.mts(1,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
22
mod.mts(1,37): error TS2322: Type '{ field: 0; }' is not assignable to type 'ImportAttributes'.
33
Property 'field' is incompatible with index signature.
44
Type 'number' is not assignable to type 'string'.
55
mod.mts(1,52): error TS2837: Import assertion values must be string literal expressions.
6-
mod.mts(3,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
6+
mod.mts(3,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
77
mod.mts(3,52): error TS2837: Import assertion values must be string literal expressions.
8-
mod.mts(5,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
8+
mod.mts(5,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
99
mod.mts(5,37): error TS2322: Type '{ field: RegExp; }' is not assignable to type 'ImportAttributes'.
1010
Property 'field' is incompatible with index signature.
1111
Type 'RegExp' is not assignable to type 'string'.
1212
mod.mts(5,52): error TS2837: Import assertion values must be string literal expressions.
13-
mod.mts(7,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
13+
mod.mts(7,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
1414
mod.mts(7,37): error TS2322: Type '{ field: string[]; }' is not assignable to type 'ImportAttributes'.
1515
Property 'field' is incompatible with index signature.
1616
Type 'string[]' is not assignable to type 'string'.
1717
mod.mts(7,52): error TS2837: Import assertion values must be string literal expressions.
18-
mod.mts(9,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
18+
mod.mts(9,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
1919
mod.mts(9,37): error TS2322: Type '{ field: { a: number; }; }' is not assignable to type 'ImportAttributes'.
2020
Property 'field' is incompatible with index signature.
2121
Type '{ a: number; }' is not assignable to type 'string'.
2222
mod.mts(9,52): error TS2837: Import assertion values must be string literal expressions.
23-
mod.mts(11,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
23+
mod.mts(11,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
2424
mod.mts(11,66): error TS2837: Import assertion values must be string literal expressions.
2525

2626

2727
==== mod.mts (16 errors) ====
2828
import * as thing1 from "./mod.mjs" assert {field: 0};
2929
~~~~~~
30-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
30+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
3131
~~~~~~~~~~~~~~~~~
3232
!!! error TS2322: Type '{ field: 0; }' is not assignable to type 'ImportAttributes'.
3333
!!! error TS2322: Property 'field' is incompatible with index signature.
@@ -37,13 +37,13 @@ mod.mts(11,66): error TS2837: Import assertion values must be string literal exp
3737

3838
import * as thing2 from "./mod.mjs" assert {field: `a`};
3939
~~~~~~
40-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
40+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
4141
~~~
4242
!!! error TS2837: Import assertion values must be string literal expressions.
4343

4444
import * as thing3 from "./mod.mjs" assert {field: /a/g};
4545
~~~~~~
46-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
46+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
4747
~~~~~~~~~~~~~~~~~~~~
4848
!!! error TS2322: Type '{ field: RegExp; }' is not assignable to type 'ImportAttributes'.
4949
!!! error TS2322: Property 'field' is incompatible with index signature.
@@ -53,7 +53,7 @@ mod.mts(11,66): error TS2837: Import assertion values must be string literal exp
5353

5454
import * as thing4 from "./mod.mjs" assert {field: ["a"]};
5555
~~~~~~
56-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
56+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
5757
~~~~~~~~~~~~~~~~~~~~~
5858
!!! error TS2322: Type '{ field: string[]; }' is not assignable to type 'ImportAttributes'.
5959
!!! error TS2322: Property 'field' is incompatible with index signature.
@@ -63,7 +63,7 @@ mod.mts(11,66): error TS2837: Import assertion values must be string literal exp
6363

6464
import * as thing5 from "./mod.mjs" assert {field: { a: 0 }};
6565
~~~~~~
66-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
66+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
6767
~~~~~~~~~~~~~~~~~~~~~~~~
6868
!!! error TS2322: Type '{ field: { a: number; }; }' is not assignable to type 'ImportAttributes'.
6969
!!! error TS2322: Property 'field' is incompatible with index signature.
@@ -73,6 +73,6 @@ mod.mts(11,66): error TS2837: Import assertion values must be string literal exp
7373

7474
import * as thing6 from "./mod.mjs" assert {type: "json", field: 0..toString()}
7575
~~~~~~
76-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
76+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
7777
~~~~~~~~~~~~~
7878
!!! error TS2837: Import assertion values must be string literal expressions.

tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
index.ts(1,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
2-
otherc.cts(1,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
1+
index.ts(1,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
2+
otherc.cts(1,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
33

44

55
==== index.ts (1 errors) ====
66
import json from "./package.json" assert { type: "json" };
77
~~~~~~
8-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
8+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
99
==== otherc.cts (1 errors) ====
1010
import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions
1111
~~~~~~
12-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
12+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
1313
const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine
1414
==== package.json (0 errors) ====
1515
{

tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=nodenext).errors.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/index.ts(6,50): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
1+
/index.ts(6,50): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
22
/index.ts(7,14): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
3-
/index.ts(7,49): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
3+
/index.ts(7,49): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
44

55

66
==== /index.ts (3 errors) ====
@@ -11,12 +11,12 @@
1111

1212
import {type RequireInterface as Req} from "pkg" assert { "resolution-mode": "require" };
1313
~~~~~~
14-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
14+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
1515
import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" };
1616
~~~~~~~~~~~~~~~
1717
!!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
1818
~~~~~~
19-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
19+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
2020
export interface Loc extends Req, Imp {}
2121

2222
export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" };

tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=nodenext).errors.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/index.ts(6,14): error TS2305: Module '"pkg"' has no exported member 'RequireInterface'.
2-
/index.ts(6,50): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
3-
/index.ts(7,49): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
2+
/index.ts(6,50): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
3+
/index.ts(7,49): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
44

55

66
==== /index.ts (3 errors) ====
@@ -13,10 +13,10 @@
1313
~~~~~~~~~~~~~~~~
1414
!!! error TS2305: Module '"pkg"' has no exported member 'RequireInterface'.
1515
~~~~~~
16-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
16+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
1717
import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" };
1818
~~~~~~
19-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
19+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
2020
export interface Loc extends Req, Imp {}
2121

2222
export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" };

tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=nodenext).errors.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
/index.ts(2,45): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
1+
/index.ts(2,45): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
22
/index.ts(2,73): error TS1453: `resolution-mode` should be either `require` or `import`.
33
/index.ts(4,10): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
4-
/index.ts(4,39): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
5-
/index.ts(6,76): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
4+
/index.ts(4,39): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
5+
/index.ts(6,76): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
66

77

88
==== /index.ts (5 errors) ====
99
// incorrect mode
1010
import type { RequireInterface } from "pkg" assert { "resolution-mode": "foobar" };
1111
~~~~~~
12-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
12+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
1313
~~~~~~~~
1414
!!! error TS1453: `resolution-mode` should be either `require` or `import`.
1515
// not type-only
1616
import { ImportInterface } from "pkg" assert { "resolution-mode": "import" };
1717
~~~~~~~~~~~~~~~
1818
!!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
1919
~~~~~~
20-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
20+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
2121
// not exclusively type-only
2222
import {type RequireInterface as Req, RequireInterface as Req2} from "pkg" assert { "resolution-mode": "require" };
2323
~~~~~~
24-
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
24+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
2525

2626
export interface LocalInterface extends RequireInterface, ImportInterface {}
2727

0 commit comments

Comments
 (0)