TypeScript/tests/cases/fourslash/completionsImport_multipleWithSameName.ts
Andy 9615e54e13 Support multiple completions with the same name but different source module (#19455)
* Support multiple completions with the same name but different source module

* Use optional parameters for source

* Simplify use of `uniques`

* Update test

* Fix `undefined` error
2017-10-26 08:22:17 -07:00

30 lines
908 B
TypeScript

/// <reference path="fourslash.ts" />
// @Filename: /global.d.ts
// A local variable would prevent import completions (see `completionsImport_shadowedByLocal.ts`), but a global doesn't.
////declare var foo: number;
// @Filename: /a.ts
////export const foo = 0;
// @Filename: /b.ts
////export const foo = 1;
// @Filename: /c.ts
////fo/**/
goTo.marker("");
verify.completionListContains("foo", "var foo: number", "", "var");
verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true);
verify.completionListContains({ name: "foo", source: "/b" }, "const foo: 1", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true);
verify.applyCodeActionFromCompletion("", {
name: "foo",
source: "/b",
description: `Import 'foo' from "./b".`,
// TODO: GH#18445
newFileContent: `import { foo } from "./b";\r
\r
fo`,
});