From 032a5742cafa348da9f4cb25edbbb61bf2d36ce8 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 26 Feb 2024 13:44:32 -0800 Subject: [PATCH] Fix auto-import tests referencing removed options --- ...sImplementInterfaceAutoImports_typeOnly.ts | 3 +- .../codeFixConvertToTypeOnlyImport1.ts | 25 ++++++++--------- .../codeFixConvertToTypeOnlyImport2.ts | 24 ++++++++-------- .../codeFixConvertToTypeOnlyImport3.ts | 28 ++++++++----------- .../completionsImport_promoteTypeOnly4.ts | 3 +- .../importNameCodeFix_importType1.ts | 3 +- .../importNameCodeFix_importType2.ts | 4 +-- .../importNameCodeFix_importType3.ts | 3 +- .../importNameCodeFix_importType8.ts | 3 +- .../fourslash/importNameCodeFix_typeOnly.ts | 3 +- .../fourslash/importNameCodeFix_typeOnly3.ts | 3 +- 11 files changed, 47 insertions(+), 55 deletions(-) diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImports_typeOnly.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImports_typeOnly.ts index 55103d11486e1..b7c67c7d59d98 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImports_typeOnly.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImports_typeOnly.ts @@ -1,6 +1,7 @@ /// -// @importsNotUsedAsValues: error +// @module: esnext +// @verbatimModuleSyntax: true // @Filename: types1.ts ////type A = {}; diff --git a/tests/cases/fourslash/codeFixConvertToTypeOnlyImport1.ts b/tests/cases/fourslash/codeFixConvertToTypeOnlyImport1.ts index d8556c97e59c3..28670a3340d45 100644 --- a/tests/cases/fourslash/codeFixConvertToTypeOnlyImport1.ts +++ b/tests/cases/fourslash/codeFixConvertToTypeOnlyImport1.ts @@ -1,6 +1,7 @@ /// -// @importsNotUsedAsValues: error +// @module: esnext +// @verbatimModuleSyntax: true // @Filename: exports.ts ////export default class A {} @@ -18,15 +19,13 @@ ////console.log(b, c); goTo.file("imports.ts"); -verify.codeFix({ - index: 0, - description: ts.Diagnostics.Use_import_type.message, - newFileContent: `import type { - B, - C, -} from './exports'; - -declare const b: B; -declare const c: C; -console.log(b, c);` -}); +// This test previously showed that a codefix could be applied to turn +// these imports, only used in type positions, into type-only imports. +// The code fix was triggered by the error issued by +// `--importsNotUsedAsValues error`, for which there is no analog in +// the compiler after its removal. `verbatimModuleSyntax` does not +// error here since the imported names are values, and so will not +// crash at runtime. Users have replaced this error and codefix with +// an eslint rule. We could consider bringing it back as a suggestion +// diagnostic, a refactor, or an organizeImports feature. +verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/codeFixConvertToTypeOnlyImport2.ts b/tests/cases/fourslash/codeFixConvertToTypeOnlyImport2.ts index 145998d985482..5156e2e0d898e 100644 --- a/tests/cases/fourslash/codeFixConvertToTypeOnlyImport2.ts +++ b/tests/cases/fourslash/codeFixConvertToTypeOnlyImport2.ts @@ -1,6 +1,7 @@ /// -// @importsNotUsedAsValues: error +// @module: esnext +// @verbatimModuleSyntax: true // @Filename: exports.ts ////export default class A {} @@ -16,14 +17,13 @@ ////console.log(a, b, c); goTo.file("imports.ts"); -verify.codeFix({ - index: 0, - description: ts.Diagnostics.Use_import_type.message, - newFileContent: `import type A from './exports'; -import type { B, C } from './exports'; - -declare const a: A; -declare const b: B; -declare const c: C; -console.log(a, b, c);` -}); +// This test previously showed that a codefix could be applied to turn +// these imports, only used in type positions, into type-only imports. +// The code fix was triggered by the error issued by +// `--importsNotUsedAsValues error`, for which there is no analog in +// the compiler after its removal. `verbatimModuleSyntax` does not +// error here since the imported names are values, and so will not +// crash at runtime. Users have replaced this error and codefix with +// an eslint rule. We could consider bringing it back as a suggestion +// diagnostic, a refactor, or an organizeImports feature. +verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/codeFixConvertToTypeOnlyImport3.ts b/tests/cases/fourslash/codeFixConvertToTypeOnlyImport3.ts index e021992ddd9db..b0bc7fb80dbac 100644 --- a/tests/cases/fourslash/codeFixConvertToTypeOnlyImport3.ts +++ b/tests/cases/fourslash/codeFixConvertToTypeOnlyImport3.ts @@ -1,6 +1,7 @@ /// -// @importsNotUsedAsValues: error +// @module: esnext +// @verbatimModuleSyntax: true // @Filename: exports1.ts ////export default class A {} @@ -24,18 +25,13 @@ ////console.log(a, b, c, d, o); goTo.file("imports.ts"); -verify.codeFixAll({ - fixId: "convertToTypeOnlyImport", - fixAllDescription: ts.Diagnostics.Fix_all_with_type_only_imports.message, - newFileContent: `import type A from './exports1'; -import type { B, C } from './exports1'; -import type D from "./exports2"; -import type * as others from "./exports2"; - -declare const a: A; -declare const b: B; -declare const c: C; -declare const d: D; -declare const o: typeof others; -console.log(a, b, c, d, o);` -}); +// This test previously showed that a codefix could be applied to turn +// these imports, only used in type positions, into type-only imports. +// The code fix was triggered by the error issued by +// `--importsNotUsedAsValues error`, for which there is no analog in +// the compiler after its removal. `verbatimModuleSyntax` does not +// error here since the imported names are values, and so will not +// crash at runtime. Users have replaced this error and codefix with +// an eslint rule. We could consider bringing it back as a suggestion +// diagnostic, a refactor, or an organizeImports feature. +verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/completionsImport_promoteTypeOnly4.ts b/tests/cases/fourslash/completionsImport_promoteTypeOnly4.ts index 3a8ec856402c5..df033219e6e38 100644 --- a/tests/cases/fourslash/completionsImport_promoteTypeOnly4.ts +++ b/tests/cases/fourslash/completionsImport_promoteTypeOnly4.ts @@ -1,7 +1,6 @@ /// // @module: es2015 -// @isolatedModules: true -// @preserveValueImports: true +// @verbatimModuleSyntax: true // @Filename: /exports.ts //// export interface SomeInterface {} diff --git a/tests/cases/fourslash/importNameCodeFix_importType1.ts b/tests/cases/fourslash/importNameCodeFix_importType1.ts index cd9dbfd319910..6e5da0f1485ad 100644 --- a/tests/cases/fourslash/importNameCodeFix_importType1.ts +++ b/tests/cases/fourslash/importNameCodeFix_importType1.ts @@ -1,7 +1,6 @@ /// -// @preserveValueImports: true -// @isolatedModules: true +// @verbatimModuleSyntax: true // @module: es2015 // @Filename: /exports.ts diff --git a/tests/cases/fourslash/importNameCodeFix_importType2.ts b/tests/cases/fourslash/importNameCodeFix_importType2.ts index f336b3e5076f5..44fd81bb70a5f 100644 --- a/tests/cases/fourslash/importNameCodeFix_importType2.ts +++ b/tests/cases/fourslash/importNameCodeFix_importType2.ts @@ -1,8 +1,6 @@ /// -// @importsNotUsedAsValues: error -// @preserveValueImports: true -// @isolatedModules: true +// @verbatimModuleSyntax: true // @module: es2015 // @Filename: /exports1.ts diff --git a/tests/cases/fourslash/importNameCodeFix_importType3.ts b/tests/cases/fourslash/importNameCodeFix_importType3.ts index 6c530b3475c19..a44d5728a87a6 100644 --- a/tests/cases/fourslash/importNameCodeFix_importType3.ts +++ b/tests/cases/fourslash/importNameCodeFix_importType3.ts @@ -1,7 +1,6 @@ /// -// @preserveValueImports: true -// @isolatedModules: true +// @verbatimModuleSyntax: true // @module: es2015 // @Filename: /exports.ts diff --git a/tests/cases/fourslash/importNameCodeFix_importType8.ts b/tests/cases/fourslash/importNameCodeFix_importType8.ts index 5cd2a583e995d..ae91a7327bd1f 100644 --- a/tests/cases/fourslash/importNameCodeFix_importType8.ts +++ b/tests/cases/fourslash/importNameCodeFix_importType8.ts @@ -1,8 +1,7 @@ /// // @module: es2015 -// @isolatedModules: true -// @preserveValueImports: true +// @verbatimModuleSyntax: true // @Filename: /exports.ts //// export interface SomeInterface {} diff --git a/tests/cases/fourslash/importNameCodeFix_typeOnly.ts b/tests/cases/fourslash/importNameCodeFix_typeOnly.ts index ad16ea4203229..4e7bfebb4b4c6 100644 --- a/tests/cases/fourslash/importNameCodeFix_typeOnly.ts +++ b/tests/cases/fourslash/importNameCodeFix_typeOnly.ts @@ -1,6 +1,7 @@ /// -// @importsNotUsedAsValues: error +// @module: esnext +// @verbatimModuleSyntax: true // @Filename: types.ts ////export class A {} diff --git a/tests/cases/fourslash/importNameCodeFix_typeOnly3.ts b/tests/cases/fourslash/importNameCodeFix_typeOnly3.ts index fdc7189200a3c..f8a4ef962f77f 100644 --- a/tests/cases/fourslash/importNameCodeFix_typeOnly3.ts +++ b/tests/cases/fourslash/importNameCodeFix_typeOnly3.ts @@ -1,6 +1,7 @@ /// -// @importsNotUsedAsValues: error +// @module: esnext +// @verbatimModuleSyntax: true // @Filename: Presenter.ts //// export type DisplayStyle = "normal" | "compact";