Skip to content

Commit

Permalink
Fix auto-import tests referencing removed options
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbranch committed Feb 26, 2024
1 parent bd8d942 commit 032a574
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference path='fourslash.ts' />

// @importsNotUsedAsValues: error
// @module: esnext
// @verbatimModuleSyntax: true

// @Filename: types1.ts
////type A = {};
Expand Down
25 changes: 12 additions & 13 deletions tests/cases/fourslash/codeFixConvertToTypeOnlyImport1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference path="fourslash.ts" />

// @importsNotUsedAsValues: error
// @module: esnext
// @verbatimModuleSyntax: true

// @Filename: exports.ts
////export default class A {}
Expand All @@ -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();
24 changes: 12 additions & 12 deletions tests/cases/fourslash/codeFixConvertToTypeOnlyImport2.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference path="fourslash.ts" />

// @importsNotUsedAsValues: error
// @module: esnext
// @verbatimModuleSyntax: true

// @Filename: exports.ts
////export default class A {}
Expand All @@ -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();
28 changes: 12 additions & 16 deletions tests/cases/fourslash/codeFixConvertToTypeOnlyImport3.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference path="fourslash.ts" />

// @importsNotUsedAsValues: error
// @module: esnext
// @verbatimModuleSyntax: true

// @Filename: exports1.ts
////export default class A {}
Expand All @@ -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();
3 changes: 1 addition & 2 deletions tests/cases/fourslash/completionsImport_promoteTypeOnly4.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference path="fourslash.ts" />
// @module: es2015
// @isolatedModules: true
// @preserveValueImports: true
// @verbatimModuleSyntax: true

// @Filename: /exports.ts
//// export interface SomeInterface {}
Expand Down
3 changes: 1 addition & 2 deletions tests/cases/fourslash/importNameCodeFix_importType1.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference path="fourslash.ts" />

// @preserveValueImports: true
// @isolatedModules: true
// @verbatimModuleSyntax: true
// @module: es2015

// @Filename: /exports.ts
Expand Down
4 changes: 1 addition & 3 deletions tests/cases/fourslash/importNameCodeFix_importType2.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/// <reference path="fourslash.ts" />

// @importsNotUsedAsValues: error
// @preserveValueImports: true
// @isolatedModules: true
// @verbatimModuleSyntax: true
// @module: es2015

// @Filename: /exports1.ts
Expand Down
3 changes: 1 addition & 2 deletions tests/cases/fourslash/importNameCodeFix_importType3.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference path="fourslash.ts" />

// @preserveValueImports: true
// @isolatedModules: true
// @verbatimModuleSyntax: true
// @module: es2015

// @Filename: /exports.ts
Expand Down
3 changes: 1 addition & 2 deletions tests/cases/fourslash/importNameCodeFix_importType8.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/// <reference path="fourslash.ts" />

// @module: es2015
// @isolatedModules: true
// @preserveValueImports: true
// @verbatimModuleSyntax: true

// @Filename: /exports.ts
//// export interface SomeInterface {}
Expand Down
3 changes: 2 additions & 1 deletion tests/cases/fourslash/importNameCodeFix_typeOnly.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference path="fourslash.ts" />

// @importsNotUsedAsValues: error
// @module: esnext
// @verbatimModuleSyntax: true

// @Filename: types.ts
////export class A {}
Expand Down
3 changes: 2 additions & 1 deletion tests/cases/fourslash/importNameCodeFix_typeOnly3.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference path="fourslash.ts" />

// @importsNotUsedAsValues: error
// @module: esnext
// @verbatimModuleSyntax: true

// @Filename: Presenter.ts
//// export type DisplayStyle = "normal" | "compact";
Expand Down

0 comments on commit 032a574

Please sign in to comment.