forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for autoimports/moveToFile to generate aliased named impo…
…rts (microsoft#59885)
- Loading branch information
Showing
5 changed files
with
197 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
/// <reference path='fourslash.ts' /> | ||
|
||
|
||
// @filename: /producer.ts | ||
//// export function doit() {} | ||
|
||
// @filename: /test.ts | ||
//// import { doit as doit2 } from "./producer"; | ||
//// | ||
//// class Another {} | ||
//// | ||
//// [|class Consumer { | ||
//// constructor() { | ||
//// doit2(); | ||
//// } | ||
//// }|] | ||
|
||
// @filename: /consumer.ts | ||
//// | ||
|
||
|
||
verify.moveToFile({ | ||
newFileContents: { | ||
"/test.ts": | ||
` | ||
class Another {} | ||
`, | ||
|
||
"/consumer.ts": | ||
`import { doit as doit2 } from "./producer"; | ||
class Consumer { | ||
constructor() { | ||
doit2(); | ||
} | ||
} | ||
` | ||
}, | ||
interactiveRefactorArguments: { targetFile: "/consumer.ts" }, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
/// <reference path='fourslash.ts' /> | ||
|
||
|
||
// @filename: /producer.ts | ||
//// export function doit() {}; | ||
//// export const x = 1; | ||
|
||
// @filename: /test.ts | ||
//// import { doit as doit2 } from "./producer"; | ||
//// | ||
//// class Another {} | ||
//// | ||
//// [|class Consumer { | ||
//// constructor() { | ||
//// doit2(); | ||
//// } | ||
//// }|] | ||
|
||
// @filename: /consumer.ts | ||
//// import { x } from "./producer"; | ||
//// x; | ||
|
||
verify.moveToFile({ | ||
newFileContents: { | ||
"/test.ts": | ||
` | ||
class Another {} | ||
`, | ||
|
||
"/consumer.ts": | ||
`import { doit as doit2, x } from "./producer"; | ||
x; | ||
class Consumer { | ||
constructor() { | ||
doit2(); | ||
} | ||
} | ||
` | ||
}, | ||
interactiveRefactorArguments: { targetFile: "/consumer.ts" }, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
/// <reference path='fourslash.ts' /> | ||
|
||
|
||
// @filename: /producer.ts | ||
//// export function doit() {}; | ||
|
||
// @filename: /test.ts | ||
//// import { doit as doit2 } from "./producer"; | ||
//// | ||
//// class Another {} | ||
//// | ||
//// [|class Consumer { | ||
//// constructor() { | ||
//// doit2(); | ||
//// } | ||
//// }|] | ||
|
||
// @filename: /consumer.ts | ||
//// import { doit } from "./producer"; // existing import does not change when alias imported | ||
//// doit(); | ||
|
||
verify.moveToFile({ | ||
newFileContents: { | ||
"/test.ts": | ||
` | ||
class Another {} | ||
`, | ||
|
||
"/consumer.ts": | ||
`import { doit } from "./producer"; // existing import does not change when alias imported | ||
doit(); | ||
class Consumer { | ||
constructor() { | ||
doit2(); | ||
} | ||
} | ||
` | ||
}, | ||
interactiveRefactorArguments: { targetFile: "/consumer.ts" }, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
/// <reference path='fourslash.ts' /> | ||
|
||
|
||
// @filename: /producer.ts | ||
//// export function doit() {} | ||
|
||
// @filename: /test.ts | ||
//// import { doit as doit2 } from "./producer"; | ||
//// | ||
//// class Another {} | ||
//// | ||
//// [|class Consumer { | ||
//// constructor() { | ||
//// doit2(); | ||
//// } | ||
//// }|] | ||
|
||
verify.moveToNewFile({ | ||
newFileContents: { | ||
"/test.ts": | ||
` | ||
class Another {} | ||
`, | ||
|
||
"/Consumer.ts": | ||
`import { doit as doit2 } from "./producer"; | ||
class Consumer { | ||
constructor() { | ||
doit2(); | ||
} | ||
} | ||
` | ||
} | ||
}); |