mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fix error message incorrectly referencing 'asserts' instead of 'assert'. (#61066)
This commit is contained in:
committed by
GitHub
parent
fed7a7f48e
commit
0652664e64
@@ -48156,7 +48156,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
|
||||
if (moduleKind === ModuleKind.NodeNext && !isImportAttributes) {
|
||||
return grammarErrorOnFirstToken(node, Diagnostics.Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_asserts);
|
||||
return grammarErrorOnFirstToken(node, Diagnostics.Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_assert);
|
||||
}
|
||||
|
||||
if (declaration.moduleSpecifier && getEmitSyntaxForModuleSpecifierExpression(declaration.moduleSpecifier) === ModuleKind.CommonJS) {
|
||||
|
||||
@@ -3983,7 +3983,7 @@
|
||||
"category": "Error",
|
||||
"code": 2879
|
||||
},
|
||||
"Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.": {
|
||||
"Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.": {
|
||||
"category": "Error",
|
||||
"code": 2880
|
||||
},
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
mod.mts(1,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
mod.mts(1,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
mod.mts(1,37): error TS2322: Type '{ field: 0; }' is not assignable to type 'ImportAttributes'.
|
||||
Property 'field' is incompatible with index signature.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
mod.mts(1,52): error TS2837: Import assertion values must be string literal expressions.
|
||||
mod.mts(3,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
mod.mts(3,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
mod.mts(3,52): error TS2837: Import assertion values must be string literal expressions.
|
||||
mod.mts(5,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
mod.mts(5,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
mod.mts(5,37): error TS2322: Type '{ field: RegExp; }' is not assignable to type 'ImportAttributes'.
|
||||
Property 'field' is incompatible with index signature.
|
||||
Type 'RegExp' is not assignable to type 'string'.
|
||||
mod.mts(5,52): error TS2837: Import assertion values must be string literal expressions.
|
||||
mod.mts(7,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
mod.mts(7,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
mod.mts(7,37): error TS2322: Type '{ field: string[]; }' is not assignable to type 'ImportAttributes'.
|
||||
Property 'field' is incompatible with index signature.
|
||||
Type 'string[]' is not assignable to type 'string'.
|
||||
mod.mts(7,52): error TS2837: Import assertion values must be string literal expressions.
|
||||
mod.mts(9,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
mod.mts(9,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
mod.mts(9,37): error TS2322: Type '{ field: { a: number; }; }' is not assignable to type 'ImportAttributes'.
|
||||
Property 'field' is incompatible with index signature.
|
||||
Type '{ a: number; }' is not assignable to type 'string'.
|
||||
mod.mts(9,52): error TS2837: Import assertion values must be string literal expressions.
|
||||
mod.mts(11,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
mod.mts(11,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
mod.mts(11,66): error TS2837: Import assertion values must be string literal expressions.
|
||||
|
||||
|
||||
==== mod.mts (16 errors) ====
|
||||
import * as thing1 from "./mod.mjs" assert {field: 0};
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ field: 0; }' is not assignable to type 'ImportAttributes'.
|
||||
!!! 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
|
||||
|
||||
import * as thing2 from "./mod.mjs" assert {field: `a`};
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
~~~
|
||||
!!! error TS2837: Import assertion values must be string literal expressions.
|
||||
|
||||
import * as thing3 from "./mod.mjs" assert {field: /a/g};
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ field: RegExp; }' is not assignable to type 'ImportAttributes'.
|
||||
!!! 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
|
||||
|
||||
import * as thing4 from "./mod.mjs" assert {field: ["a"]};
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ field: string[]; }' is not assignable to type 'ImportAttributes'.
|
||||
!!! 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
|
||||
|
||||
import * as thing5 from "./mod.mjs" assert {field: { a: 0 }};
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ field: { a: number; }; }' is not assignable to type 'ImportAttributes'.
|
||||
!!! 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
|
||||
|
||||
import * as thing6 from "./mod.mjs" assert {type: "json", field: 0..toString()}
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2837: Import assertion values must be string literal expressions.
|
||||
@@ -1,15 +1,15 @@
|
||||
index.ts(1,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
otherc.cts(1,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
index.ts(1,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
otherc.cts(1,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
|
||||
|
||||
==== index.ts (1 errors) ====
|
||||
import json from "./package.json" assert { type: "json" };
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
==== otherc.cts (1 errors) ====
|
||||
import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine
|
||||
==== package.json (0 errors) ====
|
||||
{
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
/index.ts(6,50): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
/index.ts(6,50): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
/index.ts(7,14): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
|
||||
/index.ts(7,49): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
/index.ts(7,49): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
|
||||
|
||||
==== /index.ts (3 errors) ====
|
||||
@@ -11,12 +11,12 @@
|
||||
|
||||
import {type RequireInterface as Req} from "pkg" assert { "resolution-mode": "require" };
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" };
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
export interface Loc extends Req, Imp {}
|
||||
|
||||
export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" };
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
/index.ts(6,14): error TS2305: Module '"pkg"' has no exported member 'RequireInterface'.
|
||||
/index.ts(6,50): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
/index.ts(7,49): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
/index.ts(6,50): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
/index.ts(7,49): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
|
||||
|
||||
==== /index.ts (3 errors) ====
|
||||
@@ -13,10 +13,10 @@
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2305: Module '"pkg"' has no exported member 'RequireInterface'.
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" };
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
export interface Loc extends Req, Imp {}
|
||||
|
||||
export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" };
|
||||
|
||||
+6
-6
@@ -1,15 +1,15 @@
|
||||
/index.ts(2,45): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
/index.ts(2,45): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
/index.ts(2,73): error TS1453: `resolution-mode` should be either `require` or `import`.
|
||||
/index.ts(4,10): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
|
||||
/index.ts(4,39): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
/index.ts(6,76): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
/index.ts(4,39): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
/index.ts(6,76): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
|
||||
|
||||
==== /index.ts (5 errors) ====
|
||||
// incorrect mode
|
||||
import type { RequireInterface } from "pkg" assert { "resolution-mode": "foobar" };
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
~~~~~~~~
|
||||
!!! error TS1453: `resolution-mode` should be either `require` or `import`.
|
||||
// not type-only
|
||||
@@ -17,11 +17,11 @@
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'.
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
// not exclusively type-only
|
||||
import {type RequireInterface as Req, RequireInterface as Req2} from "pkg" assert { "resolution-mode": "require" };
|
||||
~~~~~~
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.
|
||||
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
|
||||
|
||||
export interface LocalInterface extends RequireInterface, ImportInterface {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user