TypeScript/tests/cases/fourslash/refactorConvertImport_namedToNamespace.ts
Andy 43bf039a94
Add refactor to convert namespace to named imports and back (#24469)
* Add refactor to convert namespace to named imports and back

* Add tests and comments

* Code review

* Handle shorthand property assignment and re-export

* Don't use forEachFreeIdentifier

* Fix rename after "."
2018-05-30 14:11:53 -07:00

25 lines
646 B
TypeScript

/// <reference path='fourslash.ts' />
/////*a*/import { x, y as z, T } from "m";/*b*/
////const m = 0;
////const o = { x };
////export { x }; // Need a named import for this
////z;
////const n: T = 0;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert import",
actionName: "Convert named imports to namespace import",
actionDescription: "Convert named imports to namespace import",
newContent:
// TODO: GH#23781 (m_1.y shouldn't be indented)
`import * as m_1 from "m";
import { x } from "m";
const m = 0;
const o = { x: m_1.x };
export { x }; // Need a named import for this
m_1.y;
const n: m_1.T = 0;`,
});