From e60635e7abc2ee71a92cdd0fca59e821dec84008 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 20 Feb 2026 14:19:58 -0800 Subject: [PATCH 1/3] Deprecate assert in import() --- src/compiler/checker.ts | 3 + .../importTypeAssertionDeprecation.errors.txt | 15 +++ .../importTypeAssertionDeprecation.symbols | 18 +++ .../importTypeAssertionDeprecation.types | 18 +++ ...TypeModeDeclarationEmit1(module=node16).js | 12 +- ...odeDeclarationEmit1(module=node16).symbols | 8 +- ...eModeDeclarationEmit1(module=node16).types | 20 +-- ...TypeModeDeclarationEmit1(module=node18).js | 12 +- ...odeDeclarationEmit1(module=node18).symbols | 8 +- ...eModeDeclarationEmit1(module=node18).types | 20 +-- ...TypeModeDeclarationEmit1(module=node20).js | 12 +- ...odeDeclarationEmit1(module=node20).symbols | 8 +- ...eModeDeclarationEmit1(module=node20).types | 20 +-- ...peModeDeclarationEmit1(module=nodenext).js | 12 +- ...eDeclarationEmit1(module=nodenext).symbols | 8 +- ...odeDeclarationEmit1(module=nodenext).types | 20 +-- ...ationEmitErrors1(module=node16).errors.txt | 44 +++++-- ...deDeclarationEmitErrors1(module=node16).js | 12 +- ...larationEmitErrors1(module=node16).symbols | 8 +- ...eclarationEmitErrors1(module=node16).types | 20 +-- ...ationEmitErrors1(module=node18).errors.txt | 44 +++++-- ...deDeclarationEmitErrors1(module=node18).js | 12 +- ...larationEmitErrors1(module=node18).symbols | 8 +- ...eclarationEmitErrors1(module=node18).types | 20 +-- ...ationEmitErrors1(module=node20).errors.txt | 44 +++++-- ...deDeclarationEmitErrors1(module=node20).js | 12 +- ...larationEmitErrors1(module=node20).symbols | 8 +- ...eclarationEmitErrors1(module=node20).types | 20 +-- ...ionEmitErrors1(module=nodenext).errors.txt | 44 +++++-- ...DeclarationEmitErrors1(module=nodenext).js | 12 +- ...rationEmitErrors1(module=nodenext).symbols | 8 +- ...larationEmitErrors1(module=nodenext).types | 20 +-- .../parseAssertEntriesError.errors.txt | 122 +++++++++--------- .../reference/parseAssertEntriesError.js | 16 +-- .../reference/parseAssertEntriesError.symbols | 14 +- .../reference/parseAssertEntriesError.types | 44 +++---- ...ortType1(moduleresolution=bundler).symbols | 14 +- ...mportType1(moduleresolution=bundler).types | 8 +- ...Type1(moduleresolution=classic).errors.txt | 8 +- ...ortType1(moduleresolution=classic).symbols | 14 +- ...mportType1(moduleresolution=classic).types | 8 +- .../importTypeAssertionDeprecation.ts | 11 ++ .../importTypeAssertionDeprecationIgnored.ts | 13 ++ .../cases/compiler/parseAssertEntriesError.ts | 8 +- .../resolutionModeImportType1.ts | 8 +- ...deModulesImportTypeModeDeclarationEmit1.ts | 8 +- ...lesImportTypeModeDeclarationEmitErrors1.ts | 8 +- 47 files changed, 514 insertions(+), 340 deletions(-) create mode 100644 tests/baselines/reference/importTypeAssertionDeprecation.errors.txt create mode 100644 tests/baselines/reference/importTypeAssertionDeprecation.symbols create mode 100644 tests/baselines/reference/importTypeAssertionDeprecation.types create mode 100644 tests/cases/compiler/importTypeAssertionDeprecation.ts create mode 100644 tests/cases/compiler/importTypeAssertionDeprecationIgnored.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8fa3c4fce2a4a..d9cffa24ef181 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -43020,6 +43020,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { checkSourceElement(node.argument); if (node.attributes) { + if (node.attributes.token !== SyntaxKind.WithKeyword && compilerOptions.ignoreDeprecations !== "6.0") { + grammarErrorOnFirstToken(node.attributes, Diagnostics.Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_assert); + } getResolutionModeOverride(node.attributes, grammarErrorOnNode); } checkTypeReferenceOrImport(node); diff --git a/tests/baselines/reference/importTypeAssertionDeprecation.errors.txt b/tests/baselines/reference/importTypeAssertionDeprecation.errors.txt new file mode 100644 index 0000000000000..d7b447323ebfb --- /dev/null +++ b/tests/baselines/reference/importTypeAssertionDeprecation.errors.txt @@ -0,0 +1,15 @@ +/main.ts(1,38): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. +/main.ts(2,38): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. + + +==== /types.d.ts (0 errors) ==== + export interface MyType { x: string } + +==== /main.ts (2 errors) ==== + type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType; + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. + type B = import("./types", { assert: { "resolution-mode": "require" } }).MyType; + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. + \ No newline at end of file diff --git a/tests/baselines/reference/importTypeAssertionDeprecation.symbols b/tests/baselines/reference/importTypeAssertionDeprecation.symbols new file mode 100644 index 0000000000000..c651f0abd7044 --- /dev/null +++ b/tests/baselines/reference/importTypeAssertionDeprecation.symbols @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/importTypeAssertionDeprecation.ts] //// + +=== /types.d.ts === +export interface MyType { x: string } +>MyType : Symbol(MyType, Decl(types.d.ts, 0, 0)) +>x : Symbol(MyType.x, Decl(types.d.ts, 0, 25)) + +=== /main.ts === +// Should be deprecated - uses 'assert' instead of 'with' +type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType; +>A : Symbol(A, Decl(main.ts, 0, 0)) +>MyType : Symbol(MyType, Decl(types.d.ts, 0, 0)) + +// Should be fine - uses 'with' +type B = import("./types", { with: { "resolution-mode": "import" } }).MyType; +>B : Symbol(B, Decl(main.ts, 1, 79)) +>MyType : Symbol(MyType, Decl(types.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/importTypeAssertionDeprecation.types b/tests/baselines/reference/importTypeAssertionDeprecation.types new file mode 100644 index 0000000000000..8228b5ffdbf7c --- /dev/null +++ b/tests/baselines/reference/importTypeAssertionDeprecation.types @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/importTypeAssertionDeprecation.ts] //// + +=== /types.d.ts === +export interface MyType { x: string } +>x : string +> : ^^^^^^ + +=== /main.ts === +// Should be deprecated - uses 'assert' instead of 'with' +type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType; +>A : import("./types").MyType +> : ^^^^^^^^^^^^^^^^^^^^^^^^ + +// Should be fine - uses 'with' +type B = import("./types", { with: { "resolution-mode": "import" } }).MyType; +>B : import("./types").MyType +> : ^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).js b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).js index 6c0a3531fac79..da9d486b8c175 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).js +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).js @@ -15,11 +15,11 @@ export interface ImportInterface {} export interface RequireInterface {} //// [index.ts] export type LocalInterface = - & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); //// [index.js] @@ -31,6 +31,6 @@ exports.b = null; //// [index.d.ts] -export type LocalInterface = import("pkg", { assert: { "resolution-mode": "require" } }).RequireInterface & import("pkg", { assert: { "resolution-mode": "import" } }).ImportInterface; -export declare const a: import("pkg").RequireInterface; +export type LocalInterface = import("pkg", { with: { "resolution-mode": "require" } }).RequireInterface & import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; +export declare const a: import("pkg", { with: { "resolution-mode": "require" } }).RequireInterface; export declare const b: import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).symbols b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).symbols index 7558565243724..be1676ef79d9f 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).symbols +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).symbols @@ -4,17 +4,17 @@ export type LocalInterface = >LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface); >a : Symbol(a, Decl(index.ts, 4, 12)) >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : Symbol(b, Decl(index.ts, 5, 12)) >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).types b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).types index d6c415af73fde..5ff69f13324c6 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).types +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).types @@ -5,25 +5,25 @@ export type LocalInterface = >LocalInterface : LocalInterface > : ^^^^^^^^^^^^^^ - & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface); >a : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface) : import("pkg").RequireInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface : import("pkg").RequireInterface +>(null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface) : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface : import("pkg").RequireInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +>(null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any === /node_modules/pkg/import.d.ts === diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node18).js b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node18).js index 6c0a3531fac79..da9d486b8c175 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node18).js +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node18).js @@ -15,11 +15,11 @@ export interface ImportInterface {} export interface RequireInterface {} //// [index.ts] export type LocalInterface = - & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); //// [index.js] @@ -31,6 +31,6 @@ exports.b = null; //// [index.d.ts] -export type LocalInterface = import("pkg", { assert: { "resolution-mode": "require" } }).RequireInterface & import("pkg", { assert: { "resolution-mode": "import" } }).ImportInterface; -export declare const a: import("pkg").RequireInterface; +export type LocalInterface = import("pkg", { with: { "resolution-mode": "require" } }).RequireInterface & import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; +export declare const a: import("pkg", { with: { "resolution-mode": "require" } }).RequireInterface; export declare const b: import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node18).symbols b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node18).symbols index 7558565243724..be1676ef79d9f 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node18).symbols +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node18).symbols @@ -4,17 +4,17 @@ export type LocalInterface = >LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface); >a : Symbol(a, Decl(index.ts, 4, 12)) >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : Symbol(b, Decl(index.ts, 5, 12)) >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node18).types b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node18).types index d6c415af73fde..5ff69f13324c6 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node18).types +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node18).types @@ -5,25 +5,25 @@ export type LocalInterface = >LocalInterface : LocalInterface > : ^^^^^^^^^^^^^^ - & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface); >a : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface) : import("pkg").RequireInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface : import("pkg").RequireInterface +>(null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface) : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface : import("pkg").RequireInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +>(null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any === /node_modules/pkg/import.d.ts === diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node20).js b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node20).js index 6c0a3531fac79..da9d486b8c175 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node20).js +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node20).js @@ -15,11 +15,11 @@ export interface ImportInterface {} export interface RequireInterface {} //// [index.ts] export type LocalInterface = - & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); //// [index.js] @@ -31,6 +31,6 @@ exports.b = null; //// [index.d.ts] -export type LocalInterface = import("pkg", { assert: { "resolution-mode": "require" } }).RequireInterface & import("pkg", { assert: { "resolution-mode": "import" } }).ImportInterface; -export declare const a: import("pkg").RequireInterface; +export type LocalInterface = import("pkg", { with: { "resolution-mode": "require" } }).RequireInterface & import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; +export declare const a: import("pkg", { with: { "resolution-mode": "require" } }).RequireInterface; export declare const b: import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node20).symbols b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node20).symbols index 7558565243724..be1676ef79d9f 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node20).symbols +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node20).symbols @@ -4,17 +4,17 @@ export type LocalInterface = >LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface); >a : Symbol(a, Decl(index.ts, 4, 12)) >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : Symbol(b, Decl(index.ts, 5, 12)) >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node20).types b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node20).types index d6c415af73fde..5ff69f13324c6 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node20).types +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node20).types @@ -5,25 +5,25 @@ export type LocalInterface = >LocalInterface : LocalInterface > : ^^^^^^^^^^^^^^ - & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface); >a : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface) : import("pkg").RequireInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface : import("pkg").RequireInterface +>(null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface) : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface : import("pkg").RequireInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +>(null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any === /node_modules/pkg/import.d.ts === diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=nodenext).js b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=nodenext).js index 6c0a3531fac79..da9d486b8c175 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=nodenext).js +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=nodenext).js @@ -15,11 +15,11 @@ export interface ImportInterface {} export interface RequireInterface {} //// [index.ts] export type LocalInterface = - & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); //// [index.js] @@ -31,6 +31,6 @@ exports.b = null; //// [index.d.ts] -export type LocalInterface = import("pkg", { assert: { "resolution-mode": "require" } }).RequireInterface & import("pkg", { assert: { "resolution-mode": "import" } }).ImportInterface; -export declare const a: import("pkg").RequireInterface; +export type LocalInterface = import("pkg", { with: { "resolution-mode": "require" } }).RequireInterface & import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; +export declare const a: import("pkg", { with: { "resolution-mode": "require" } }).RequireInterface; export declare const b: import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=nodenext).symbols index 7558565243724..be1676ef79d9f 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=nodenext).symbols +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=nodenext).symbols @@ -4,17 +4,17 @@ export type LocalInterface = >LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface); >a : Symbol(a, Decl(index.ts, 4, 12)) >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : Symbol(b, Decl(index.ts, 5, 12)) >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=nodenext).types b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=nodenext).types index d6c415af73fde..5ff69f13324c6 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=nodenext).types +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=nodenext).types @@ -5,25 +5,25 @@ export type LocalInterface = >LocalInterface : LocalInterface > : ^^^^^^^^^^^^^^ - & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface); >a : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface) : import("pkg").RequireInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface : import("pkg").RequireInterface +>(null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface) : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface : import("pkg").RequireInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +>(null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any === /node_modules/pkg/import.d.ts === diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).errors.txt index 5172f49a5c8cd..acceeec7b9de5 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).errors.txt @@ -1,5 +1,5 @@ -/index.ts(2,51): error TS1453: `resolution-mode` should be either `require` or `import`. -/index.ts(5,78): error TS1453: `resolution-mode` should be either `require` or `import`. +/index.ts(2,49): error TS1453: `resolution-mode` should be either `require` or `import`. +/index.ts(5,76): error TS1453: `resolution-mode` should be either `require` or `import`. /other.ts(3,7): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? /other.ts(3,22): error TS1005: 'with' expected. /other.ts(3,39): error TS1005: ';' expected. @@ -27,10 +27,14 @@ /other.ts(7,79): error TS1434: Unexpected keyword or identifier. /other.ts(7,79): error TS2304: Cannot find name 'ImportInterface'. /other.ts(7,94): error TS1128: Declaration or statement expected. +/other2.ts(3,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(3,32): error TS1455: `resolution-mode` is the only valid key for type import assertions. +/other2.ts(4,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(4,32): error TS1455: `resolution-mode` is the only valid key for type import assertions. /other2.ts(4,52): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. +/other2.ts(6,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(6,59): error TS1455: `resolution-mode` is the only valid key for type import assertions. +/other2.ts(7,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(7,59): error TS1455: `resolution-mode` is the only valid key for type import assertions. /other2.ts(7,79): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. /other3.ts(3,7): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? @@ -67,10 +71,14 @@ /other4.ts(10,56): error TS1005: ',' expected. /other4.ts(10,57): error TS1134: Variable declaration expected. /other4.ts(10,73): error TS1005: ',' expected. +/other5.ts(2,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(2,31): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. +/other5.ts(3,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(3,31): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. /other5.ts(3,37): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. +/other5.ts(5,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(5,58): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. +/other5.ts(6,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(6,58): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. /other5.ts(6,64): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. @@ -90,15 +98,15 @@ export interface RequireInterface {} ==== /index.ts (2 errors) ==== export type LocalInterface = - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface - ~~~~~~~~ + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface + ~~~~~~~~ !!! error TS1453: `resolution-mode` should be either `require` or `import`. - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; - export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); - ~~~~~~~~ + export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); + ~~~~~~~~ !!! error TS1453: `resolution-mode` should be either `require` or `import`. - export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); + export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); ==== /other.ts (27 errors) ==== // missing assert: export type LocalInterface = @@ -164,22 +172,30 @@ !!! error TS2304: Cannot find name 'ImportInterface'. ~ !!! error TS1128: Declaration or statement expected. -==== /other2.ts (6 errors) ==== +==== /other2.ts (10 errors) ==== // wrong assertion key export type LocalInterface = & import("pkg", { assert: {"bad": "require"} }).RequireInterface + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. & import("pkg", { assert: {"bad": "import"} }).ImportInterface; + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. ~~~~~~~~~~~~~~~ !!! error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. export const a = (null as any as import("pkg", { assert: {"bad": "require"} }).RequireInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. export const b = (null as any as import("pkg", { assert: {"bad": "import"} }).ImportInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. ~~~~~~~~~~~~~~~ @@ -280,21 +296,29 @@ !!! error TS1134: Variable declaration expected. ~ !!! error TS1005: ',' expected. -==== /other5.ts (6 errors) ==== +==== /other5.ts (10 errors) ==== export type LocalInterface = & import("pkg", { assert: {} }).RequireInterface + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. & import("pkg", { assert: {} }).ImportInterface; + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. ~~~~~~~~~~~~~~~ !!! error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. export const a = (null as any as import("pkg", { assert: {} }).RequireInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. export const b = (null as any as import("pkg", { assert: {} }).ImportInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. ~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).js b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).js index 813770edf9748..a4297c36f50bf 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).js +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).js @@ -15,11 +15,11 @@ export interface ImportInterface {} export interface RequireInterface {} //// [index.ts] export type LocalInterface = - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); //// [other.ts] // missing assert: export type LocalInterface = @@ -120,8 +120,8 @@ exports.b = null; //// [index.d.ts] -export type LocalInterface = import("pkg", { assert: { "resolution-mode": "foobar" } }).RequireInterface & import("pkg", { assert: { "resolution-mode": "import" } }).ImportInterface; -export declare const a: import("pkg").RequireInterface; +export type LocalInterface = import("pkg", { with: { "resolution-mode": "foobar" } }).RequireInterface & import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; +export declare const a: import("pkg", { with: { "resolution-mode": "foobar" } }).RequireInterface; export declare const b: import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; //// [other.d.ts] export type LocalInterface = import("pkg", { with: {} }); diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).symbols b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).symbols index 7413ce6dd65e5..ab3333a40ddb1 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).symbols +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).symbols @@ -12,17 +12,17 @@ export interface RequireInterface {} export type LocalInterface = >LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); >a : Symbol(a, Decl(index.ts, 4, 12)) >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : Symbol(b, Decl(index.ts, 5, 12)) >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).types b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).types index ab9012548d13a..9318c9dad7e41 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).types +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).types @@ -11,26 +11,26 @@ export type LocalInterface = >LocalInterface : LocalInterface > : ^^^^^^^^^^^^^^ - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); >a : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface) : import("pkg").RequireInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface : import("pkg").RequireInterface +>(null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface) : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface : import("pkg").RequireInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any > : ^^^ -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +>(null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any > : ^^^ diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).errors.txt b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).errors.txt index 5172f49a5c8cd..acceeec7b9de5 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).errors.txt +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).errors.txt @@ -1,5 +1,5 @@ -/index.ts(2,51): error TS1453: `resolution-mode` should be either `require` or `import`. -/index.ts(5,78): error TS1453: `resolution-mode` should be either `require` or `import`. +/index.ts(2,49): error TS1453: `resolution-mode` should be either `require` or `import`. +/index.ts(5,76): error TS1453: `resolution-mode` should be either `require` or `import`. /other.ts(3,7): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? /other.ts(3,22): error TS1005: 'with' expected. /other.ts(3,39): error TS1005: ';' expected. @@ -27,10 +27,14 @@ /other.ts(7,79): error TS1434: Unexpected keyword or identifier. /other.ts(7,79): error TS2304: Cannot find name 'ImportInterface'. /other.ts(7,94): error TS1128: Declaration or statement expected. +/other2.ts(3,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(3,32): error TS1455: `resolution-mode` is the only valid key for type import assertions. +/other2.ts(4,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(4,32): error TS1455: `resolution-mode` is the only valid key for type import assertions. /other2.ts(4,52): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. +/other2.ts(6,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(6,59): error TS1455: `resolution-mode` is the only valid key for type import assertions. +/other2.ts(7,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(7,59): error TS1455: `resolution-mode` is the only valid key for type import assertions. /other2.ts(7,79): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. /other3.ts(3,7): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? @@ -67,10 +71,14 @@ /other4.ts(10,56): error TS1005: ',' expected. /other4.ts(10,57): error TS1134: Variable declaration expected. /other4.ts(10,73): error TS1005: ',' expected. +/other5.ts(2,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(2,31): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. +/other5.ts(3,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(3,31): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. /other5.ts(3,37): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. +/other5.ts(5,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(5,58): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. +/other5.ts(6,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(6,58): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. /other5.ts(6,64): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. @@ -90,15 +98,15 @@ export interface RequireInterface {} ==== /index.ts (2 errors) ==== export type LocalInterface = - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface - ~~~~~~~~ + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface + ~~~~~~~~ !!! error TS1453: `resolution-mode` should be either `require` or `import`. - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; - export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); - ~~~~~~~~ + export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); + ~~~~~~~~ !!! error TS1453: `resolution-mode` should be either `require` or `import`. - export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); + export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); ==== /other.ts (27 errors) ==== // missing assert: export type LocalInterface = @@ -164,22 +172,30 @@ !!! error TS2304: Cannot find name 'ImportInterface'. ~ !!! error TS1128: Declaration or statement expected. -==== /other2.ts (6 errors) ==== +==== /other2.ts (10 errors) ==== // wrong assertion key export type LocalInterface = & import("pkg", { assert: {"bad": "require"} }).RequireInterface + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. & import("pkg", { assert: {"bad": "import"} }).ImportInterface; + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. ~~~~~~~~~~~~~~~ !!! error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. export const a = (null as any as import("pkg", { assert: {"bad": "require"} }).RequireInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. export const b = (null as any as import("pkg", { assert: {"bad": "import"} }).ImportInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. ~~~~~~~~~~~~~~~ @@ -280,21 +296,29 @@ !!! error TS1134: Variable declaration expected. ~ !!! error TS1005: ',' expected. -==== /other5.ts (6 errors) ==== +==== /other5.ts (10 errors) ==== export type LocalInterface = & import("pkg", { assert: {} }).RequireInterface + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. & import("pkg", { assert: {} }).ImportInterface; + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. ~~~~~~~~~~~~~~~ !!! error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. export const a = (null as any as import("pkg", { assert: {} }).RequireInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. export const b = (null as any as import("pkg", { assert: {} }).ImportInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. ~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).js b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).js index 813770edf9748..a4297c36f50bf 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).js +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).js @@ -15,11 +15,11 @@ export interface ImportInterface {} export interface RequireInterface {} //// [index.ts] export type LocalInterface = - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); //// [other.ts] // missing assert: export type LocalInterface = @@ -120,8 +120,8 @@ exports.b = null; //// [index.d.ts] -export type LocalInterface = import("pkg", { assert: { "resolution-mode": "foobar" } }).RequireInterface & import("pkg", { assert: { "resolution-mode": "import" } }).ImportInterface; -export declare const a: import("pkg").RequireInterface; +export type LocalInterface = import("pkg", { with: { "resolution-mode": "foobar" } }).RequireInterface & import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; +export declare const a: import("pkg", { with: { "resolution-mode": "foobar" } }).RequireInterface; export declare const b: import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; //// [other.d.ts] export type LocalInterface = import("pkg", { with: {} }); diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).symbols b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).symbols index 7413ce6dd65e5..ab3333a40ddb1 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).symbols +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).symbols @@ -12,17 +12,17 @@ export interface RequireInterface {} export type LocalInterface = >LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); >a : Symbol(a, Decl(index.ts, 4, 12)) >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : Symbol(b, Decl(index.ts, 5, 12)) >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).types b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).types index ab9012548d13a..9318c9dad7e41 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).types +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).types @@ -11,26 +11,26 @@ export type LocalInterface = >LocalInterface : LocalInterface > : ^^^^^^^^^^^^^^ - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); >a : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface) : import("pkg").RequireInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface : import("pkg").RequireInterface +>(null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface) : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface : import("pkg").RequireInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any > : ^^^ -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +>(null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any > : ^^^ diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).errors.txt b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).errors.txt index 5172f49a5c8cd..acceeec7b9de5 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).errors.txt +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).errors.txt @@ -1,5 +1,5 @@ -/index.ts(2,51): error TS1453: `resolution-mode` should be either `require` or `import`. -/index.ts(5,78): error TS1453: `resolution-mode` should be either `require` or `import`. +/index.ts(2,49): error TS1453: `resolution-mode` should be either `require` or `import`. +/index.ts(5,76): error TS1453: `resolution-mode` should be either `require` or `import`. /other.ts(3,7): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? /other.ts(3,22): error TS1005: 'with' expected. /other.ts(3,39): error TS1005: ';' expected. @@ -27,10 +27,14 @@ /other.ts(7,79): error TS1434: Unexpected keyword or identifier. /other.ts(7,79): error TS2304: Cannot find name 'ImportInterface'. /other.ts(7,94): error TS1128: Declaration or statement expected. +/other2.ts(3,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(3,32): error TS1455: `resolution-mode` is the only valid key for type import assertions. +/other2.ts(4,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(4,32): error TS1455: `resolution-mode` is the only valid key for type import assertions. /other2.ts(4,52): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. +/other2.ts(6,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(6,59): error TS1455: `resolution-mode` is the only valid key for type import assertions. +/other2.ts(7,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(7,59): error TS1455: `resolution-mode` is the only valid key for type import assertions. /other2.ts(7,79): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. /other3.ts(3,7): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? @@ -67,10 +71,14 @@ /other4.ts(10,56): error TS1005: ',' expected. /other4.ts(10,57): error TS1134: Variable declaration expected. /other4.ts(10,73): error TS1005: ',' expected. +/other5.ts(2,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(2,31): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. +/other5.ts(3,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(3,31): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. /other5.ts(3,37): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. +/other5.ts(5,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(5,58): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. +/other5.ts(6,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(6,58): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. /other5.ts(6,64): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. @@ -90,15 +98,15 @@ export interface RequireInterface {} ==== /index.ts (2 errors) ==== export type LocalInterface = - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface - ~~~~~~~~ + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface + ~~~~~~~~ !!! error TS1453: `resolution-mode` should be either `require` or `import`. - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; - export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); - ~~~~~~~~ + export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); + ~~~~~~~~ !!! error TS1453: `resolution-mode` should be either `require` or `import`. - export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); + export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); ==== /other.ts (27 errors) ==== // missing assert: export type LocalInterface = @@ -164,22 +172,30 @@ !!! error TS2304: Cannot find name 'ImportInterface'. ~ !!! error TS1128: Declaration or statement expected. -==== /other2.ts (6 errors) ==== +==== /other2.ts (10 errors) ==== // wrong assertion key export type LocalInterface = & import("pkg", { assert: {"bad": "require"} }).RequireInterface + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. & import("pkg", { assert: {"bad": "import"} }).ImportInterface; + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. ~~~~~~~~~~~~~~~ !!! error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. export const a = (null as any as import("pkg", { assert: {"bad": "require"} }).RequireInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. export const b = (null as any as import("pkg", { assert: {"bad": "import"} }).ImportInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. ~~~~~~~~~~~~~~~ @@ -280,21 +296,29 @@ !!! error TS1134: Variable declaration expected. ~ !!! error TS1005: ',' expected. -==== /other5.ts (6 errors) ==== +==== /other5.ts (10 errors) ==== export type LocalInterface = & import("pkg", { assert: {} }).RequireInterface + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. & import("pkg", { assert: {} }).ImportInterface; + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. ~~~~~~~~~~~~~~~ !!! error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. export const a = (null as any as import("pkg", { assert: {} }).RequireInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. export const b = (null as any as import("pkg", { assert: {} }).ImportInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. ~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).js b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).js index 813770edf9748..a4297c36f50bf 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).js +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).js @@ -15,11 +15,11 @@ export interface ImportInterface {} export interface RequireInterface {} //// [index.ts] export type LocalInterface = - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); //// [other.ts] // missing assert: export type LocalInterface = @@ -120,8 +120,8 @@ exports.b = null; //// [index.d.ts] -export type LocalInterface = import("pkg", { assert: { "resolution-mode": "foobar" } }).RequireInterface & import("pkg", { assert: { "resolution-mode": "import" } }).ImportInterface; -export declare const a: import("pkg").RequireInterface; +export type LocalInterface = import("pkg", { with: { "resolution-mode": "foobar" } }).RequireInterface & import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; +export declare const a: import("pkg", { with: { "resolution-mode": "foobar" } }).RequireInterface; export declare const b: import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; //// [other.d.ts] export type LocalInterface = import("pkg", { with: {} }); diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).symbols b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).symbols index 7413ce6dd65e5..ab3333a40ddb1 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).symbols +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).symbols @@ -12,17 +12,17 @@ export interface RequireInterface {} export type LocalInterface = >LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); >a : Symbol(a, Decl(index.ts, 4, 12)) >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : Symbol(b, Decl(index.ts, 5, 12)) >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).types b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).types index ab9012548d13a..9318c9dad7e41 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).types +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).types @@ -11,26 +11,26 @@ export type LocalInterface = >LocalInterface : LocalInterface > : ^^^^^^^^^^^^^^ - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); >a : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface) : import("pkg").RequireInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface : import("pkg").RequireInterface +>(null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface) : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface : import("pkg").RequireInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any > : ^^^ -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +>(null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any > : ^^^ diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).errors.txt index 5172f49a5c8cd..acceeec7b9de5 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).errors.txt @@ -1,5 +1,5 @@ -/index.ts(2,51): error TS1453: `resolution-mode` should be either `require` or `import`. -/index.ts(5,78): error TS1453: `resolution-mode` should be either `require` or `import`. +/index.ts(2,49): error TS1453: `resolution-mode` should be either `require` or `import`. +/index.ts(5,76): error TS1453: `resolution-mode` should be either `require` or `import`. /other.ts(3,7): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? /other.ts(3,22): error TS1005: 'with' expected. /other.ts(3,39): error TS1005: ';' expected. @@ -27,10 +27,14 @@ /other.ts(7,79): error TS1434: Unexpected keyword or identifier. /other.ts(7,79): error TS2304: Cannot find name 'ImportInterface'. /other.ts(7,94): error TS1128: Declaration or statement expected. +/other2.ts(3,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(3,32): error TS1455: `resolution-mode` is the only valid key for type import assertions. +/other2.ts(4,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(4,32): error TS1455: `resolution-mode` is the only valid key for type import assertions. /other2.ts(4,52): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. +/other2.ts(6,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(6,59): error TS1455: `resolution-mode` is the only valid key for type import assertions. +/other2.ts(7,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other2.ts(7,59): error TS1455: `resolution-mode` is the only valid key for type import assertions. /other2.ts(7,79): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. /other3.ts(3,7): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? @@ -67,10 +71,14 @@ /other4.ts(10,56): error TS1005: ',' expected. /other4.ts(10,57): error TS1134: Variable declaration expected. /other4.ts(10,73): error TS1005: ',' expected. +/other5.ts(2,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(2,31): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. +/other5.ts(3,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(3,31): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. /other5.ts(3,37): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. +/other5.ts(5,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(5,58): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. +/other5.ts(6,58): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /other5.ts(6,58): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. /other5.ts(6,64): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. @@ -90,15 +98,15 @@ export interface RequireInterface {} ==== /index.ts (2 errors) ==== export type LocalInterface = - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface - ~~~~~~~~ + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface + ~~~~~~~~ !!! error TS1453: `resolution-mode` should be either `require` or `import`. - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; - export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); - ~~~~~~~~ + export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); + ~~~~~~~~ !!! error TS1453: `resolution-mode` should be either `require` or `import`. - export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); + export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); ==== /other.ts (27 errors) ==== // missing assert: export type LocalInterface = @@ -164,22 +172,30 @@ !!! error TS2304: Cannot find name 'ImportInterface'. ~ !!! error TS1128: Declaration or statement expected. -==== /other2.ts (6 errors) ==== +==== /other2.ts (10 errors) ==== // wrong assertion key export type LocalInterface = & import("pkg", { assert: {"bad": "require"} }).RequireInterface + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. & import("pkg", { assert: {"bad": "import"} }).ImportInterface; + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. ~~~~~~~~~~~~~~~ !!! error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. export const a = (null as any as import("pkg", { assert: {"bad": "require"} }).RequireInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. export const b = (null as any as import("pkg", { assert: {"bad": "import"} }).ImportInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~~~~ !!! error TS1455: `resolution-mode` is the only valid key for type import assertions. ~~~~~~~~~~~~~~~ @@ -280,21 +296,29 @@ !!! error TS1134: Variable declaration expected. ~ !!! error TS1005: ',' expected. -==== /other5.ts (6 errors) ==== +==== /other5.ts (10 errors) ==== export type LocalInterface = & import("pkg", { assert: {} }).RequireInterface + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. & import("pkg", { assert: {} }).ImportInterface; + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. ~~~~~~~~~~~~~~~ !!! error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. export const a = (null as any as import("pkg", { assert: {} }).RequireInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. export const b = (null as any as import("pkg", { assert: {} }).ImportInterface); + ~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ~~ !!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. ~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).js b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).js index 813770edf9748..a4297c36f50bf 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).js +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).js @@ -15,11 +15,11 @@ export interface ImportInterface {} export interface RequireInterface {} //// [index.ts] export type LocalInterface = - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); //// [other.ts] // missing assert: export type LocalInterface = @@ -120,8 +120,8 @@ exports.b = null; //// [index.d.ts] -export type LocalInterface = import("pkg", { assert: { "resolution-mode": "foobar" } }).RequireInterface & import("pkg", { assert: { "resolution-mode": "import" } }).ImportInterface; -export declare const a: import("pkg").RequireInterface; +export type LocalInterface = import("pkg", { with: { "resolution-mode": "foobar" } }).RequireInterface & import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; +export declare const a: import("pkg", { with: { "resolution-mode": "foobar" } }).RequireInterface; export declare const b: import("pkg", { with: { "resolution-mode": "import" } }).ImportInterface; //// [other.d.ts] export type LocalInterface = import("pkg", { with: {} }); diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).symbols index 7413ce6dd65e5..ab3333a40ddb1 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).symbols +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).symbols @@ -12,17 +12,17 @@ export interface RequireInterface {} export type LocalInterface = >LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); >a : Symbol(a, Decl(index.ts, 4, 12)) >RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : Symbol(b, Decl(index.ts, 5, 12)) >ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).types b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).types index ab9012548d13a..9318c9dad7e41 100644 --- a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).types +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).types @@ -11,26 +11,26 @@ export type LocalInterface = >LocalInterface : LocalInterface > : ^^^^^^^^^^^^^^ - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); >a : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface) : import("pkg").RequireInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface : import("pkg").RequireInterface +>(null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface) : import("pkg").RequireInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface : import("pkg").RequireInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any > : ^^^ -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); >b : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->(null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +>(null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface) : import("./node_modules/pkg/import").ImportInterface > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface : import("./node_modules/pkg/import").ImportInterface +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >null as any : any > : ^^^ diff --git a/tests/baselines/reference/parseAssertEntriesError.errors.txt b/tests/baselines/reference/parseAssertEntriesError.errors.txt index b0784172a9a0a..09c325fc82797 100644 --- a/tests/baselines/reference/parseAssertEntriesError.errors.txt +++ b/tests/baselines/reference/parseAssertEntriesError.errors.txt @@ -1,110 +1,110 @@ /index.ts(2,7): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? -/index.ts(2,32): error TS1478: Identifier or string literal expected. -/index.ts(2,32): error TS2695: Left side of comma operator is unused and has no side effects. -/index.ts(2,55): error TS1005: ';' expected. +/index.ts(2,30): error TS1478: Identifier or string literal expected. +/index.ts(2,30): error TS2695: Left side of comma operator is unused and has no side effects. +/index.ts(2,53): error TS1005: ';' expected. +/index.ts(2,64): error TS1128: Declaration or statement expected. /index.ts(2,66): error TS1128: Declaration or statement expected. +/index.ts(2,67): error TS1128: Declaration or statement expected. /index.ts(2,68): error TS1128: Declaration or statement expected. -/index.ts(2,69): error TS1128: Declaration or statement expected. -/index.ts(2,70): error TS1128: Declaration or statement expected. -/index.ts(2,71): error TS2304: Cannot find name 'RequireInterface'. -/index.ts(3,36): error TS1005: ':' expected. -/index.ts(3,70): error TS2339: Property 'ImportInterface' does not exist on type 'Promise<{ default: typeof import("/node_modules/pkg/import"); }>'. +/index.ts(2,69): error TS2304: Cannot find name 'RequireInterface'. +/index.ts(3,34): error TS1005: ':' expected. +/index.ts(3,68): error TS2339: Property 'ImportInterface' does not exist on type 'Promise<{ default: typeof import("/node_modules/pkg/import"); }>'. /index.ts(5,34): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? -/index.ts(5,59): error TS1478: Identifier or string literal expected. -/index.ts(5,59): error TS2695: Left side of comma operator is unused and has no side effects. -/index.ts(5,82): error TS1005: ';' expected. +/index.ts(5,57): error TS1478: Identifier or string literal expected. +/index.ts(5,57): error TS2695: Left side of comma operator is unused and has no side effects. +/index.ts(5,80): error TS1005: ';' expected. +/index.ts(5,91): error TS1128: Declaration or statement expected. /index.ts(5,93): error TS1128: Declaration or statement expected. +/index.ts(5,94): error TS1128: Declaration or statement expected. /index.ts(5,95): error TS1128: Declaration or statement expected. -/index.ts(5,96): error TS1128: Declaration or statement expected. -/index.ts(5,97): error TS1128: Declaration or statement expected. -/index.ts(5,98): error TS1434: Unexpected keyword or identifier. -/index.ts(5,98): error TS2304: Cannot find name 'RequireInterface'. -/index.ts(5,114): error TS1128: Declaration or statement expected. +/index.ts(5,96): error TS1434: Unexpected keyword or identifier. +/index.ts(5,96): error TS2304: Cannot find name 'RequireInterface'. +/index.ts(5,112): error TS1128: Declaration or statement expected. /index.ts(6,34): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? -/index.ts(6,59): error TS1478: Identifier or string literal expected. -/index.ts(6,59): error TS2695: Left side of comma operator is unused and has no side effects. -/index.ts(6,82): error TS1005: ';' expected. +/index.ts(6,57): error TS1478: Identifier or string literal expected. +/index.ts(6,57): error TS2695: Left side of comma operator is unused and has no side effects. +/index.ts(6,80): error TS1005: ';' expected. +/index.ts(6,90): error TS1128: Declaration or statement expected. /index.ts(6,92): error TS1128: Declaration or statement expected. +/index.ts(6,93): error TS1128: Declaration or statement expected. /index.ts(6,94): error TS1128: Declaration or statement expected. -/index.ts(6,95): error TS1128: Declaration or statement expected. -/index.ts(6,96): error TS1128: Declaration or statement expected. -/index.ts(6,97): error TS1434: Unexpected keyword or identifier. -/index.ts(6,97): error TS2304: Cannot find name 'ImportInterface'. -/index.ts(6,112): error TS1128: Declaration or statement expected. +/index.ts(6,95): error TS1434: Unexpected keyword or identifier. +/index.ts(6,95): error TS2304: Cannot find name 'ImportInterface'. +/index.ts(6,110): error TS1128: Declaration or statement expected. ==== /index.ts (33 errors) ==== export type LocalInterface = - & import("pkg", { assert: {1234, "resolution-mode": "require"} }).RequireInterface - ~~~~~~~~~~~~~~~~~~~~~~~~~ + & import("pkg", { with: {1234, "resolution-mode": "require"} }).RequireInterface + ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? - ~~~~ + ~~~~ !!! error TS1478: Identifier or string literal expected. - ~~~~ + ~~~~ !!! error TS2695: Left side of comma operator is unused and has no side effects. - ~ + ~ !!! error TS1005: ';' expected. - ~ + ~ !!! error TS1128: Declaration or statement expected. - ~ + ~ !!! error TS1128: Declaration or statement expected. - ~ + ~ !!! error TS1128: Declaration or statement expected. - ~ + ~ !!! error TS1128: Declaration or statement expected. - ~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'RequireInterface'. - & import("pkg", { assert: {1234, "resolution-mode": "import"} }).ImportInterface; - ~ + & import("pkg", { with: {1234, "resolution-mode": "import"} }).ImportInterface; + ~ !!! error TS1005: ':' expected. - ~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'ImportInterface' does not exist on type 'Promise<{ default: typeof import("/node_modules/pkg/import"); }>'. - export const a = (null as any as import("pkg", { assert: {1234, "resolution-mode": "require"} }).RequireInterface); - ~~~~~~~~~~~~~~~~~~~~~~~~~ + export const a = (null as any as import("pkg", { with: {1234, "resolution-mode": "require"} }).RequireInterface); + ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? - ~~~~ + ~~~~ !!! error TS1478: Identifier or string literal expected. - ~~~~ + ~~~~ !!! error TS2695: Left side of comma operator is unused and has no side effects. - ~ + ~ !!! error TS1005: ';' expected. - ~ + ~ !!! error TS1128: Declaration or statement expected. - ~ + ~ !!! error TS1128: Declaration or statement expected. - ~ + ~ !!! error TS1128: Declaration or statement expected. - ~ + ~ !!! error TS1128: Declaration or statement expected. - ~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~ !!! error TS1434: Unexpected keyword or identifier. - ~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'RequireInterface'. - ~ + ~ !!! error TS1128: Declaration or statement expected. - export const b = (null as any as import("pkg", { assert: {1234, "resolution-mode": "import"} }).ImportInterface); - ~~~~~~~~~~~~~~~~~~~~~~~~~ + export const b = (null as any as import("pkg", { with: {1234, "resolution-mode": "import"} }).ImportInterface); + ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? - ~~~~ + ~~~~ !!! error TS1478: Identifier or string literal expected. - ~~~~ + ~~~~ !!! error TS2695: Left side of comma operator is unused and has no side effects. - ~ + ~ !!! error TS1005: ';' expected. - ~ + ~ !!! error TS1128: Declaration or statement expected. - ~ + ~ !!! error TS1128: Declaration or statement expected. - ~ + ~ !!! error TS1128: Declaration or statement expected. - ~ + ~ !!! error TS1128: Declaration or statement expected. - ~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~ !!! error TS1434: Unexpected keyword or identifier. - ~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'ImportInterface'. - ~ + ~ !!! error TS1128: Declaration or statement expected. ==== /node_modules/pkg/package.json (0 errors) ==== diff --git a/tests/baselines/reference/parseAssertEntriesError.js b/tests/baselines/reference/parseAssertEntriesError.js index 28a0c7bc234d4..f15c3e2b748c5 100644 --- a/tests/baselines/reference/parseAssertEntriesError.js +++ b/tests/baselines/reference/parseAssertEntriesError.js @@ -15,11 +15,11 @@ export interface ImportInterface {} export interface RequireInterface {} //// [index.ts] export type LocalInterface = - & import("pkg", { assert: {1234, "resolution-mode": "require"} }).RequireInterface - & import("pkg", { assert: {1234, "resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {1234, "resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {1234, "resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {1234, "resolution-mode": "require"} }).RequireInterface); -export const b = (null as any as import("pkg", { assert: {1234, "resolution-mode": "import"} }).ImportInterface); +export const a = (null as any as import("pkg", { with: {1234, "resolution-mode": "require"} }).RequireInterface); +export const b = (null as any as import("pkg", { with: {1234, "resolution-mode": "import"} }).ImportInterface); //// [index.js] @@ -29,7 +29,7 @@ exports.b = exports.a = void 0; 1234, "resolution-mode"; "require"; RequireInterface - & import("pkg", { assert: { 1234: , "resolution-mode": "import" } }).ImportInterface; + & import("pkg", { with: { 1234: , "resolution-mode": "import" } }).ImportInterface; exports.a = null; 1234, "resolution-mode"; "require"; @@ -43,6 +43,6 @@ ImportInterface; //// [index.d.ts] -export type LocalInterface = import("pkg", { assert: {} }); -export declare const a: any; -export declare const b: any; +export type LocalInterface = import("pkg", { with: {} }); +export declare const a: import("pkg", { with: {} }); +export declare const b: import("pkg", { with: {} }); diff --git a/tests/baselines/reference/parseAssertEntriesError.symbols b/tests/baselines/reference/parseAssertEntriesError.symbols index 07ec89c3b2dbc..f7890a26f3fa3 100644 --- a/tests/baselines/reference/parseAssertEntriesError.symbols +++ b/tests/baselines/reference/parseAssertEntriesError.symbols @@ -4,17 +4,17 @@ export type LocalInterface = >LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) - & import("pkg", { assert: {1234, "resolution-mode": "require"} }).RequireInterface - & import("pkg", { assert: {1234, "resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {1234, "resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {1234, "resolution-mode": "import"} }).ImportInterface; >"pkg" : Symbol("./node_modules/pkg/import", Decl(import.d.ts, 0, 0)) ->assert : Symbol(assert, Decl(index.ts, 2, 21)) ->1234 : Symbol(1234, Decl(index.ts, 2, 31)) ->"resolution-mode" : Symbol("resolution-mode", Decl(index.ts, 2, 36)) +>with : Symbol(with, Decl(index.ts, 2, 21)) +>1234 : Symbol(1234, Decl(index.ts, 2, 29)) +>"resolution-mode" : Symbol("resolution-mode", Decl(index.ts, 2, 34)) -export const a = (null as any as import("pkg", { assert: {1234, "resolution-mode": "require"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {1234, "resolution-mode": "require"} }).RequireInterface); >a : Symbol(a, Decl(index.ts, 4, 12)) -export const b = (null as any as import("pkg", { assert: {1234, "resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {1234, "resolution-mode": "import"} }).ImportInterface); >b : Symbol(b, Decl(index.ts, 5, 12)) === /node_modules/pkg/import.d.ts === diff --git a/tests/baselines/reference/parseAssertEntriesError.types b/tests/baselines/reference/parseAssertEntriesError.types index dc152ffb0da0a..9ea001bf17753 100644 --- a/tests/baselines/reference/parseAssertEntriesError.types +++ b/tests/baselines/reference/parseAssertEntriesError.types @@ -5,7 +5,7 @@ export type LocalInterface = >LocalInterface : any > : ^^^ - & import("pkg", { assert: {1234, "resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {1234, "resolution-mode": "require"} }).RequireInterface >1234, "resolution-mode" : "resolution-mode" > : ^^^^^^^^^^^^^^^^^ >1234 : 1234 @@ -14,22 +14,22 @@ export type LocalInterface = > : ^^^^^^^^^^^^^^^^^ >"require" : "require" > : ^^^^^^^^^ ->RequireInterface & import("pkg", { assert: {1234, "resolution-mode": "import"} }).ImportInterface : number -> : ^^^^^^ +>RequireInterface & import("pkg", { with: {1234, "resolution-mode": "import"} }).ImportInterface : number +> : ^^^^^^ >RequireInterface : any > : ^^^ - & import("pkg", { assert: {1234, "resolution-mode": "import"} }).ImportInterface; ->import("pkg", { assert: {1234, "resolution-mode": "import"} }).ImportInterface : any -> : ^^^ ->import("pkg", { assert: {1234, "resolution-mode": "import"} }) : Promise<{ default: typeof import("./node_modules/pkg/import"); }> -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + & import("pkg", { with: {1234, "resolution-mode": "import"} }).ImportInterface; +>import("pkg", { with: {1234, "resolution-mode": "import"} }).ImportInterface : any +> : ^^^ +>import("pkg", { with: {1234, "resolution-mode": "import"} }) : Promise<{ default: typeof import("./node_modules/pkg/import"); }> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >"pkg" : "pkg" > : ^^^^^ ->{ assert: {1234, "resolution-mode": "import"} } : { assert: { 1234: any; "resolution-mode": string; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->assert : { 1234: any; "resolution-mode": string; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ with: {1234, "resolution-mode": "import"} } : { with: { 1234: any; "resolution-mode": string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>with : { 1234: any; "resolution-mode": string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >{1234, "resolution-mode": "import"} : { 1234: any; "resolution-mode": string; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >1234 : any @@ -43,13 +43,13 @@ export type LocalInterface = >ImportInterface : any > : ^^^ -export const a = (null as any as import("pkg", { assert: {1234, "resolution-mode": "require"} }).RequireInterface); +export const a = (null as any as import("pkg", { with: {1234, "resolution-mode": "require"} }).RequireInterface); >a : any > : ^^^ ->(null as any as import("pkg", { assert: { : any -> : ^^^ ->null as any as import("pkg", { assert: { : any -> : ^^^ +>(null as any as import("pkg", { with: { : any +> : ^^^ +>null as any as import("pkg", { with: { : any +> : ^^^ >null as any : any > : ^^^ >1234, "resolution-mode" : "resolution-mode" @@ -63,13 +63,13 @@ export const a = (null as any as import("pkg", { assert: {1234, "resolution-mode >RequireInterface : any > : ^^^ -export const b = (null as any as import("pkg", { assert: {1234, "resolution-mode": "import"} }).ImportInterface); +export const b = (null as any as import("pkg", { with: {1234, "resolution-mode": "import"} }).ImportInterface); >b : any > : ^^^ ->(null as any as import("pkg", { assert: { : any -> : ^^^ ->null as any as import("pkg", { assert: { : any -> : ^^^ +>(null as any as import("pkg", { with: { : any +> : ^^^ +>null as any as import("pkg", { with: { : any +> : ^^^ >null as any : any > : ^^^ >1234, "resolution-mode" : "resolution-mode" diff --git a/tests/baselines/reference/resolutionModeImportType1(moduleresolution=bundler).symbols b/tests/baselines/reference/resolutionModeImportType1(moduleresolution=bundler).symbols index 3b36b51d0afa7..8a0cd461fdb99 100644 --- a/tests/baselines/reference/resolutionModeImportType1(moduleresolution=bundler).symbols +++ b/tests/baselines/reference/resolutionModeImportType1(moduleresolution=bundler).symbols @@ -13,21 +13,21 @@ type Default = typeof import("foo").x; >Default : Symbol(Default, Decl(app.ts, 0, 0)) >x : Symbol(x, Decl(index.d.mts, 0, 20)) -type Import = typeof import("foo", { assert: { "resolution-mode": "import" } }).x; +type Import = typeof import("foo", { with: { "resolution-mode": "import" } }).x; >Import : Symbol(Import, Decl(app.ts, 0, 38)) >x : Symbol(x, Decl(index.d.mts, 0, 20)) -type Require = typeof import("foo", { assert: { "resolution-mode": "require" } }).x; ->Require : Symbol(Require, Decl(app.ts, 1, 82)) +type Require = typeof import("foo", { with: { "resolution-mode": "require" } }).x; +>Require : Symbol(Require, Decl(app.ts, 1, 80)) >x : Symbol(x, Decl(index.d.cts, 0, 20)) // resolution-mode does not enforce file extension in `bundler`, just sets conditions -type ImportRelative = typeof import("./other", { assert: { "resolution-mode": "import" } }).x; ->ImportRelative : Symbol(ImportRelative, Decl(app.ts, 2, 84)) +type ImportRelative = typeof import("./other", { with: { "resolution-mode": "import" } }).x; +>ImportRelative : Symbol(ImportRelative, Decl(app.ts, 2, 82)) >x : Symbol(x, Decl(other.ts, 0, 12)) -type RequireRelative = typeof import("./other", { assert: { "resolution-mode": "require" } }).x; ->RequireRelative : Symbol(RequireRelative, Decl(app.ts, 4, 94)) +type RequireRelative = typeof import("./other", { with: { "resolution-mode": "require" } }).x; +>RequireRelative : Symbol(RequireRelative, Decl(app.ts, 4, 92)) >x : Symbol(x, Decl(other.ts, 0, 12)) === /other.ts === diff --git a/tests/baselines/reference/resolutionModeImportType1(moduleresolution=bundler).types b/tests/baselines/reference/resolutionModeImportType1(moduleresolution=bundler).types index 1c3b7739c5c65..bf72bed10cda1 100644 --- a/tests/baselines/reference/resolutionModeImportType1(moduleresolution=bundler).types +++ b/tests/baselines/reference/resolutionModeImportType1(moduleresolution=bundler).types @@ -16,23 +16,23 @@ type Default = typeof import("foo").x; > : ^^^^^^^^ >x : error -type Import = typeof import("foo", { assert: { "resolution-mode": "import" } }).x; +type Import = typeof import("foo", { with: { "resolution-mode": "import" } }).x; >Import : "module" > : ^^^^^^^^ >x : error -type Require = typeof import("foo", { assert: { "resolution-mode": "require" } }).x; +type Require = typeof import("foo", { with: { "resolution-mode": "require" } }).x; >Require : "script" > : ^^^^^^^^ >x : error // resolution-mode does not enforce file extension in `bundler`, just sets conditions -type ImportRelative = typeof import("./other", { assert: { "resolution-mode": "import" } }).x; +type ImportRelative = typeof import("./other", { with: { "resolution-mode": "import" } }).x; >ImportRelative : "other" > : ^^^^^^^ >x : error -type RequireRelative = typeof import("./other", { assert: { "resolution-mode": "require" } }).x; +type RequireRelative = typeof import("./other", { with: { "resolution-mode": "require" } }).x; >RequireRelative : "other" > : ^^^^^^^ >x : error diff --git a/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).errors.txt b/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).errors.txt index a8da8abbfd01a..33afe7ce07507 100644 --- a/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).errors.txt +++ b/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).errors.txt @@ -27,15 +27,15 @@ error TS5107: Option 'moduleResolution=classic' is deprecated and will stop func type Default = typeof import("foo").x; ~~~~~ !!! error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? - type Import = typeof import("foo", { assert: { "resolution-mode": "import" } }).x; + type Import = typeof import("foo", { with: { "resolution-mode": "import" } }).x; ~~~~~ !!! error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? - type Require = typeof import("foo", { assert: { "resolution-mode": "require" } }).x; + type Require = typeof import("foo", { with: { "resolution-mode": "require" } }).x; ~~~~~ !!! error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? // resolution-mode does not enforce file extension in `bundler`, just sets conditions - type ImportRelative = typeof import("./other", { assert: { "resolution-mode": "import" } }).x; - type RequireRelative = typeof import("./other", { assert: { "resolution-mode": "require" } }).x; + type ImportRelative = typeof import("./other", { with: { "resolution-mode": "import" } }).x; + type RequireRelative = typeof import("./other", { with: { "resolution-mode": "require" } }).x; ==== /other.ts (0 errors) ==== export const x = "other"; diff --git a/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).symbols b/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).symbols index 5d3941b76cc7c..3790234635760 100644 --- a/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).symbols +++ b/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).symbols @@ -12,19 +12,19 @@ export declare const x: "script"; type Default = typeof import("foo").x; >Default : Symbol(Default, Decl(app.ts, 0, 0)) -type Import = typeof import("foo", { assert: { "resolution-mode": "import" } }).x; +type Import = typeof import("foo", { with: { "resolution-mode": "import" } }).x; >Import : Symbol(Import, Decl(app.ts, 0, 38)) -type Require = typeof import("foo", { assert: { "resolution-mode": "require" } }).x; ->Require : Symbol(Require, Decl(app.ts, 1, 82)) +type Require = typeof import("foo", { with: { "resolution-mode": "require" } }).x; +>Require : Symbol(Require, Decl(app.ts, 1, 80)) // resolution-mode does not enforce file extension in `bundler`, just sets conditions -type ImportRelative = typeof import("./other", { assert: { "resolution-mode": "import" } }).x; ->ImportRelative : Symbol(ImportRelative, Decl(app.ts, 2, 84)) +type ImportRelative = typeof import("./other", { with: { "resolution-mode": "import" } }).x; +>ImportRelative : Symbol(ImportRelative, Decl(app.ts, 2, 82)) >x : Symbol(x, Decl(other.ts, 0, 12)) -type RequireRelative = typeof import("./other", { assert: { "resolution-mode": "require" } }).x; ->RequireRelative : Symbol(RequireRelative, Decl(app.ts, 4, 94)) +type RequireRelative = typeof import("./other", { with: { "resolution-mode": "require" } }).x; +>RequireRelative : Symbol(RequireRelative, Decl(app.ts, 4, 92)) >x : Symbol(x, Decl(other.ts, 0, 12)) === /other.ts === diff --git a/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).types b/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).types index 9eae8f8d35c9c..afc87abe092c4 100644 --- a/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).types +++ b/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).types @@ -17,26 +17,26 @@ type Default = typeof import("foo").x; >x : any > : ^^^ -type Import = typeof import("foo", { assert: { "resolution-mode": "import" } }).x; +type Import = typeof import("foo", { with: { "resolution-mode": "import" } }).x; >Import : any > : ^^^ >x : any > : ^^^ -type Require = typeof import("foo", { assert: { "resolution-mode": "require" } }).x; +type Require = typeof import("foo", { with: { "resolution-mode": "require" } }).x; >Require : any > : ^^^ >x : any > : ^^^ // resolution-mode does not enforce file extension in `bundler`, just sets conditions -type ImportRelative = typeof import("./other", { assert: { "resolution-mode": "import" } }).x; +type ImportRelative = typeof import("./other", { with: { "resolution-mode": "import" } }).x; >ImportRelative : "other" > : ^^^^^^^ >x : any > : ^^^ -type RequireRelative = typeof import("./other", { assert: { "resolution-mode": "require" } }).x; +type RequireRelative = typeof import("./other", { with: { "resolution-mode": "require" } }).x; >RequireRelative : "other" > : ^^^^^^^ >x : any diff --git a/tests/cases/compiler/importTypeAssertionDeprecation.ts b/tests/cases/compiler/importTypeAssertionDeprecation.ts new file mode 100644 index 0000000000000..e630f4d2e8dc5 --- /dev/null +++ b/tests/cases/compiler/importTypeAssertionDeprecation.ts @@ -0,0 +1,11 @@ +// @module: esnext +// @moduleResolution: bundler +// @noEmit: true +// @noTypesAndSymbols: true + +// @Filename: /types.d.ts +export interface MyType { x: string } + +// @Filename: /main.ts +type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType; +type B = import("./types", { assert: { "resolution-mode": "require" } }).MyType; diff --git a/tests/cases/compiler/importTypeAssertionDeprecationIgnored.ts b/tests/cases/compiler/importTypeAssertionDeprecationIgnored.ts new file mode 100644 index 0000000000000..b7a39bc7c2139 --- /dev/null +++ b/tests/cases/compiler/importTypeAssertionDeprecationIgnored.ts @@ -0,0 +1,13 @@ +// @module: esnext +// @moduleResolution: bundler +// @ignoreDeprecations: 6.0 +// @noEmit: true +// @noTypesAndSymbols: true + +// @Filename: /types.d.ts +export interface MyType { x: string } + +// @Filename: /main.ts +// With ignoreDeprecations: "6.0", import type assertions should not produce a deprecation error. +type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType; +type B = import("./types", { assert: { "resolution-mode": "require" } }).MyType; diff --git a/tests/cases/compiler/parseAssertEntriesError.ts b/tests/cases/compiler/parseAssertEntriesError.ts index 1ac1ae9c25d31..a7a5b03bcd5bc 100644 --- a/tests/cases/compiler/parseAssertEntriesError.ts +++ b/tests/cases/compiler/parseAssertEntriesError.ts @@ -18,8 +18,8 @@ export interface ImportInterface {} export interface RequireInterface {} // @filename: /index.ts export type LocalInterface = - & import("pkg", { assert: {1234, "resolution-mode": "require"} }).RequireInterface - & import("pkg", { assert: {1234, "resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {1234, "resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {1234, "resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {1234, "resolution-mode": "require"} }).RequireInterface); -export const b = (null as any as import("pkg", { assert: {1234, "resolution-mode": "import"} }).ImportInterface); +export const a = (null as any as import("pkg", { with: {1234, "resolution-mode": "require"} }).RequireInterface); +export const b = (null as any as import("pkg", { with: {1234, "resolution-mode": "import"} }).ImportInterface); diff --git a/tests/cases/conformance/moduleResolution/resolutionModeImportType1.ts b/tests/cases/conformance/moduleResolution/resolutionModeImportType1.ts index 7b86d8ff51efb..aca33af6ac2bf 100644 --- a/tests/cases/conformance/moduleResolution/resolutionModeImportType1.ts +++ b/tests/cases/conformance/moduleResolution/resolutionModeImportType1.ts @@ -23,11 +23,11 @@ export declare const x: "script"; // @Filename: /app.ts type Default = typeof import("foo").x; -type Import = typeof import("foo", { assert: { "resolution-mode": "import" } }).x; -type Require = typeof import("foo", { assert: { "resolution-mode": "require" } }).x; +type Import = typeof import("foo", { with: { "resolution-mode": "import" } }).x; +type Require = typeof import("foo", { with: { "resolution-mode": "require" } }).x; // resolution-mode does not enforce file extension in `bundler`, just sets conditions -type ImportRelative = typeof import("./other", { assert: { "resolution-mode": "import" } }).x; -type RequireRelative = typeof import("./other", { assert: { "resolution-mode": "require" } }).x; +type ImportRelative = typeof import("./other", { with: { "resolution-mode": "import" } }).x; +type RequireRelative = typeof import("./other", { with: { "resolution-mode": "require" } }).x; // @Filename: /other.ts export const x = "other"; diff --git a/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmit1.ts b/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmit1.ts index 208a1141dfa44..420d39e0d4f0e 100644 --- a/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmit1.ts +++ b/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmit1.ts @@ -18,8 +18,8 @@ export interface ImportInterface {} export interface RequireInterface {} // @filename: /index.ts export type LocalInterface = - & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "require"} }).RequireInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); diff --git a/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmitErrors1.ts b/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmitErrors1.ts index ca502b389790f..addf3aa80ff60 100644 --- a/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmitErrors1.ts +++ b/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmitErrors1.ts @@ -18,11 +18,11 @@ export interface ImportInterface {} export interface RequireInterface {} // @filename: /index.ts export type LocalInterface = - & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface - & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + & import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface; -export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); -export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +export const a = (null as any as import("pkg", { with: {"resolution-mode": "foobar"} }).RequireInterface); +export const b = (null as any as import("pkg", { with: {"resolution-mode": "import"} }).ImportInterface); // @filename: /other.ts // missing assert: export type LocalInterface = From 107ee581ff4032354e2ab24bf93399bd8c93f566 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 20 Feb 2026 14:40:14 -0800 Subject: [PATCH 2/3] remove unused baselines --- .../importTypeAssertionDeprecation.symbols | 18 ------------------ .../importTypeAssertionDeprecation.types | 18 ------------------ 2 files changed, 36 deletions(-) delete mode 100644 tests/baselines/reference/importTypeAssertionDeprecation.symbols delete mode 100644 tests/baselines/reference/importTypeAssertionDeprecation.types diff --git a/tests/baselines/reference/importTypeAssertionDeprecation.symbols b/tests/baselines/reference/importTypeAssertionDeprecation.symbols deleted file mode 100644 index c651f0abd7044..0000000000000 --- a/tests/baselines/reference/importTypeAssertionDeprecation.symbols +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/importTypeAssertionDeprecation.ts] //// - -=== /types.d.ts === -export interface MyType { x: string } ->MyType : Symbol(MyType, Decl(types.d.ts, 0, 0)) ->x : Symbol(MyType.x, Decl(types.d.ts, 0, 25)) - -=== /main.ts === -// Should be deprecated - uses 'assert' instead of 'with' -type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType; ->A : Symbol(A, Decl(main.ts, 0, 0)) ->MyType : Symbol(MyType, Decl(types.d.ts, 0, 0)) - -// Should be fine - uses 'with' -type B = import("./types", { with: { "resolution-mode": "import" } }).MyType; ->B : Symbol(B, Decl(main.ts, 1, 79)) ->MyType : Symbol(MyType, Decl(types.d.ts, 0, 0)) - diff --git a/tests/baselines/reference/importTypeAssertionDeprecation.types b/tests/baselines/reference/importTypeAssertionDeprecation.types deleted file mode 100644 index 8228b5ffdbf7c..0000000000000 --- a/tests/baselines/reference/importTypeAssertionDeprecation.types +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/importTypeAssertionDeprecation.ts] //// - -=== /types.d.ts === -export interface MyType { x: string } ->x : string -> : ^^^^^^ - -=== /main.ts === -// Should be deprecated - uses 'assert' instead of 'with' -type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType; ->A : import("./types").MyType -> : ^^^^^^^^^^^^^^^^^^^^^^^^ - -// Should be fine - uses 'with' -type B = import("./types", { with: { "resolution-mode": "import" } }).MyType; ->B : import("./types").MyType -> : ^^^^^^^^^^^^^^^^^^^^^^^^ - From 7b92ae5c8fde037cb3628d4eaea821c7b40fc804 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 20 Feb 2026 15:57:24 -0800 Subject: [PATCH 3/3] call nodes too, this is sus --- src/compiler/checker.ts | 8 ++++++++ .../importTypeAssertionDeprecation.errors.txt | 11 ++++++++++- .../cases/compiler/importTypeAssertionDeprecation.ts | 3 +++ .../compiler/importTypeAssertionDeprecationIgnored.ts | 3 +++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d9cffa24ef181..b030c144bb826 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -37952,6 +37952,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (importCallOptionsType !== emptyObjectType) { checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, TypeFlags.Undefined), node.arguments[1]); } + if (compilerOptions.ignoreDeprecations !== "6.0" && isObjectLiteralExpression(node.arguments[1])) { + for (const prop of node.arguments[1].properties) { + if (isPropertyAssignment(prop) && isIdentifier(prop.name) && prop.name.escapedText === "assert") { + grammarErrorOnNode(prop.name, Diagnostics.Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_assert); + break; + } + } + } } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal diff --git a/tests/baselines/reference/importTypeAssertionDeprecation.errors.txt b/tests/baselines/reference/importTypeAssertionDeprecation.errors.txt index d7b447323ebfb..bf729a428325d 100644 --- a/tests/baselines/reference/importTypeAssertionDeprecation.errors.txt +++ b/tests/baselines/reference/importTypeAssertionDeprecation.errors.txt @@ -1,15 +1,24 @@ /main.ts(1,38): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. /main.ts(2,38): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. +/main.ts(4,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. +/main.ts(5,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. ==== /types.d.ts (0 errors) ==== export interface MyType { x: string } -==== /main.ts (2 errors) ==== +==== /main.ts (4 errors) ==== type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType; ~ !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. type B = import("./types", { assert: { "resolution-mode": "require" } }).MyType; ~ !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. + + const a = import("./types", { assert: { "resolution-mode": "import" } }); + ~~~~~~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. + const b = import("./types", { assert: { "resolution-mode": "require" } }); + ~~~~~~ +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. \ No newline at end of file diff --git a/tests/cases/compiler/importTypeAssertionDeprecation.ts b/tests/cases/compiler/importTypeAssertionDeprecation.ts index e630f4d2e8dc5..62b2a5de07aa9 100644 --- a/tests/cases/compiler/importTypeAssertionDeprecation.ts +++ b/tests/cases/compiler/importTypeAssertionDeprecation.ts @@ -9,3 +9,6 @@ export interface MyType { x: string } // @Filename: /main.ts type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType; type B = import("./types", { assert: { "resolution-mode": "require" } }).MyType; + +const a = import("./types", { assert: { "resolution-mode": "import" } }); +const b = import("./types", { assert: { "resolution-mode": "require" } }); diff --git a/tests/cases/compiler/importTypeAssertionDeprecationIgnored.ts b/tests/cases/compiler/importTypeAssertionDeprecationIgnored.ts index b7a39bc7c2139..1b52873c15565 100644 --- a/tests/cases/compiler/importTypeAssertionDeprecationIgnored.ts +++ b/tests/cases/compiler/importTypeAssertionDeprecationIgnored.ts @@ -11,3 +11,6 @@ export interface MyType { x: string } // With ignoreDeprecations: "6.0", import type assertions should not produce a deprecation error. type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType; type B = import("./types", { assert: { "resolution-mode": "require" } }).MyType; + +const a = import("./types", { assert: { "resolution-mode": "import" } }); +const b = import("./types", { assert: { "resolution-mode": "require" } });