mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Support import fix/completions for export = (#25708)
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
////fooB/*1*/
|
||||
|
||||
goTo.marker("0");
|
||||
const preferences = { includeCompletionsForModuleExports: true };
|
||||
const preferences: FourSlashInterface.UserPreferences = { includeCompletionsForModuleExports: true };
|
||||
verify.completions(
|
||||
{ marker: "0", excludes: { name: "default", source: "/src/foo-bar" }, preferences },
|
||||
{ marker: "1", includes: { name: "fooBar", source: "/src/foo-bar", sourceDisplay: "./foo-bar", text: "(property) default: 0", kind: "property", hasAction: true }, preferences }
|
||||
|
||||
53
tests/cases/fourslash/completionsImport_exportEquals.ts
Normal file
53
tests/cases/fourslash/completionsImport_exportEquals.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/// <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, },
|
||||
preferences,
|
||||
},
|
||||
{
|
||||
marker: "1",
|
||||
includes: { name: "b", source: "/a", hasAction: true },
|
||||
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;`,
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
verify.completions({
|
||||
marker: "",
|
||||
// Tester will assert that it is only included once
|
||||
includes: [{ name: "foo", hasAction: true }],
|
||||
includes: [{ name: "foo", source: "a", hasAction: true }],
|
||||
preferences: {
|
||||
includeCompletionsForModuleExports: true,
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
verify.completions({
|
||||
marker: "",
|
||||
includes: { name: "Foo", source: "/a.tsx", hasAction: true },
|
||||
includes: { name: "Foo", source: "/a", hasAction: true },
|
||||
excludes: "Bar",
|
||||
preferences: {
|
||||
includeCompletionsForModuleExports: true,
|
||||
|
||||
@@ -24,7 +24,7 @@ verify.completions({
|
||||
marker: "",
|
||||
exact: [
|
||||
"n",
|
||||
{ name: "publicSym", insertText: "[publicSym]", replacementSpan: test.ranges()[0], hasAction: true },
|
||||
{ name: "publicSym", source: "/a", insertText: "[publicSym]", replacementSpan: test.ranges()[0], hasAction: true },
|
||||
],
|
||||
preferences: {
|
||||
includeInsertTextCompletions: true,
|
||||
|
||||
@@ -37,11 +37,11 @@ verify.codeFixAll({
|
||||
fixId: "fixMissingImport",
|
||||
fixAllDescription: "Add all missing imports",
|
||||
newFileContent:
|
||||
// TODO: GH#25135 (should import 'e')
|
||||
`import bd, * as b from "./b";
|
||||
import cd, { c0 } from "./c";
|
||||
import dd, { d0, d1 } from "./d";
|
||||
import ad, { a0 } from "./a";
|
||||
import e = require("./e");
|
||||
|
||||
ad; ad; a0; a0;
|
||||
bd; bd; b.b0; b.b0;
|
||||
|
||||
25
tests/cases/fourslash/importNameCodeFix_exportEquals.ts
Normal file
25
tests/cases/fourslash/importNameCodeFix_exportEquals.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: /a.d.ts
|
||||
////declare function a(): void;
|
||||
////declare namespace a {
|
||||
//// export interface b {}
|
||||
////}
|
||||
////export = a;
|
||||
|
||||
// @Filename: /b.ts
|
||||
////a;
|
||||
////let x: b;
|
||||
|
||||
goTo.file("/b.ts");
|
||||
verify.codeFixAll({
|
||||
fixId: "fixMissingImport",
|
||||
fixAllDescription: "Add all missing imports",
|
||||
newFileContent:
|
||||
`import { b } from "./a";
|
||||
|
||||
import a = require("./a");
|
||||
|
||||
a;
|
||||
let x: b;`,
|
||||
});
|
||||
Reference in New Issue
Block a user