Currently if the new file cannot be resolved, it would be newFile.ts. Later I would have to manually update the filename. And in the case when updateImportsOnFileMove.enabled is set to falsey, I'll have to rename the references to the new files too.
Would be better to show an input for filename when no reasonable guess for the new file name exists.
Maybe show this ability to name the file always?
If I'm refactoring code out of another file I'll most likely want to rename it something different than the class/function/variable name. Maybe this could be put into a setting to always prompt for file name?
I also think this makes sense from a consistency-perspective.
When you extract a function inside a file, you're asked for a function-name - you don't have to accept a default name, and then apply the rename-refactoring.
The same should apply to this. Support for this should ideally be present in tsserver so this behaviour can easily be replicated in other editors too.
I suggest one more request, that for quick refactoring and consistency, we could use a flag like - nameStrategy: [common name strategy] - to quick move function to a new file.
Also, i think for now, the new files are always located in the current folder aside as original file, could we set a different file path when using the filename open box?
I'm with @sevenryze here... We prefer to use kebab-casing for our file names, so I'd like to have that as a setting when moving a function to a new file.
We could also use formatting in a setting like we do with the window-title
"window.title": "${dirty}${activeEditorMedium}${separator}${rootPath}"
not sure exactly how we'd say stuff like "IFoo" => "foo.interface.ts" or something... would require some regex capture-style stuff with built-in functions like "table case", "camelCase", "dashify" or whatever.
Would love to have the dialog prompt minimally though. Right now I have to rename the file every time
Would be great if this could show an input with predefined options in both pascal case and kebab case for quick picking, but also allow manual changes.
So for example, initiating a move of class SomeClassName to a new file would show a VSCode native input box (such as the command pallette one) that lets you pick from SomeClassName.ts and some-class-name.ts or allow you to type your own.
Possibly helpful:
https://www.npmjs.com/package/dasherize
Upon digging further it seems the new file name comes from typescript itself which doesn't offer the possiblity of overriding the file name. An issue might need to be opened in the TS repo as well.
https://github.com/microsoft/TypeScript/blob/master/src/services/refactors/moveToNewFile.ts#L50-L54
Most helpful comment
I suggest one more request, that for quick refactoring and consistency, we could use a flag like - nameStrategy: [common name strategy] - to quick move function to a new file.
Also, i think for now, the new files are always located in the current folder aside as original file, could we set a different file path when using the filename open box?