move-ts icon indicating copy to clipboard operation
move-ts copied to clipboard

Move TS declarations to existing file with import update

Open musikobios opened this issue 3 years ago • 1 comments

Hello there! This is an ask for new feature not an actual issue. It would be really helpful to move some TS declarations to already existing files eg. move from a.ts and append to b.ts, and auto update the imports of c.ts.

// (a.ts)
-export type MyType {
-  x: string;
-  y: boolean;
-  z: object;
-}

and append to existing b.ts:

// b.ts
export type OldType {
  field: number;
}

+export type MyType {
+  x: string;
+  y: boolean;
+  z: object;
+}

So the imports of c.ts will now become:

// c.ts
- import MyType from "./a.ts"
+ import MyType from "./b.ts"

musikobios avatar Oct 05 '22 12:10 musikobios

This is already a built-in feature of VSCode. Select code, press Ctrl/Cmd+., select "Move to file". All imports everywhere will be updated. image

Papooch avatar Nov 07 '23 19:11 Papooch