TypeScript/tests/cases/fourslash/completionsImport_exportEquals.ts
Andrew Branch e1bce187a8
Type-only auto imports (#36412)
* WIP

* Promote existing type-only imports to regular if needed

* Add completions test adding to type-only import

* Update tests, revert whole-import-clause replacement codefix strategy to preserve import specifier formatting

* Revert unnecessary changes

* Delete unused function

* }
2020-01-27 12:53:32 -08:00

63 lines
1.3 KiB
TypeScript

/// <reference path="fourslash.ts" />
// @module: commonjs
// @Filename: /a.d.ts
////declare function a(): void;
////declare namespace a {
//// export interface b {}
////}
////export = a;
// @Filename: /b.ts
////a/*0*/;
////let x: b/*1*/;
const preferences: FourSlashInterface.UserPreferences = { includeCompletionsForModuleExports: true };
verify.completions(
{
marker: "0",
includes: {
name: "a",
source: "/a",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences,
},
{
marker: "1",
includes: {
name: "b",
source: "/a",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences,
}
);
// Import { b } first, or it will just add a qualified name from 'a' (which isn't what we're trying to test)
verify.applyCodeActionFromCompletion("1", {
name: "b",
source: "/a",
description: `Import 'b' from module "./a"`,
newFileContent:
`import { b } from "./a";
a;
let x: b;`,
});
verify.applyCodeActionFromCompletion("0", {
name: "a",
source: "/a",
description: `Import 'a' from module "./a"`,
newFileContent:
`import { b } from "./a";
import a = require("./a");
a;
let x: b;`,
});