From 0652664e6408f7704395fc53fe245e2e77367fe8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 28 Jan 2025 14:42:35 -0800 Subject: [PATCH] Fix error message incorrectly referencing 'asserts' instead of 'assert'. (#61066) --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- .../importAssertionNonstring.errors.txt | 24 +++++++++---------- ...portAssertions(module=nodenext).errors.txt | 8 +++---- ...clarationEmit1(module=nodenext).errors.txt | 8 +++---- ...clarationEmit2(module=nodenext).errors.txt | 8 +++---- ...ionEmitErrors1(module=nodenext).errors.txt | 12 +++++----- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ded639b7a09cf..fcb93c45dc1dd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b6dc93964940d..0d7e0bb39a8d4 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -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 }, diff --git a/tests/baselines/reference/importAssertionNonstring.errors.txt b/tests/baselines/reference/importAssertionNonstring.errors.txt index 20df276c17cc0..a220b1f213eaa 100644 --- a/tests/baselines/reference/importAssertionNonstring.errors.txt +++ b/tests/baselines/reference/importAssertionNonstring.errors.txt @@ -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. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt index 667a16dc4a59b..1b09957ba0b0d 100644 --- a/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt @@ -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) ==== { diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=nodenext).errors.txt index 85d78cd955097..d2c0a64f66744 100644 --- a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=nodenext).errors.txt @@ -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" }; diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=nodenext).errors.txt index c9a427dbbfe63..77b7ff5cd3914 100644 --- a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=nodenext).errors.txt @@ -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" }; diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=nodenext).errors.txt index dbb1ccdb5af49..11d577b0ea7d6 100644 --- a/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=nodenext).errors.txt @@ -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 {}