You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suggested refactoring: move function/type/class to new file #13859
I suggest adding a refactoring/code fix that helps with the task of moving a class/function/type or other top level declaration out of the current file and into another file, updating references as needed.
Motivation
Often when starting out with a new feature it makes sense to start to write code in a single file while working out the design. However, as soon as long method bodies start getting implemented or when code gets checked in to version control, it makes less sense and gets harder to work with and you want to move top level members into separate files.
I've found CodeRush and ReSharper's "Move Type to File" tool (for VS/C#) very useful in this workflow and I miss it greatly when working with TypeScript/VS Code.
I suggest that this type of feature should require as little input as possible, ideally just be a single shortcut without dialogs, generating an appropriately named file.
It needs to take module configuration into consideration (i.e. should import/export be generated or not)
Should generate .tsx extension as appropriate, either based on the file it is invoked in or the contents of the code transferred.
Is this something that could be considered for inclusion in the compiler, or is it out of scope and should instead be suggested as a plug-in to editors/IDE's?
Well, it's not about moving a file but moving a declaration out of one file into another. I guess a lot of the mechanics of updating references will be the same, but is it the same?
Activity
markusjohnsson commentedon Feb 27, 2017
Is this something that could be considered for inclusion in the compiler, or is it out of scope and should instead be suggested as a plug-in to editors/IDE's?
mhegazy commentedon Feb 27, 2017
Should be covered by #6487
markusjohnsson commentedon Feb 27, 2017
Well, it's not about moving a file but moving a declaration out of one file into another. I guess a lot of the mechanics of updating references will be the same, but is it the same?
mhegazy commentedon Feb 27, 2017
will leave both then.