I want to do some type mapping like this:
There are some modules with id
and actions
, I want to combine all actions method and remap its method name adding ${id}/
prefix, sample code is here:
const m1 = {
id: 'm1',
actions: {
down(id: string) {
return true;
},
up(n: number) {
return 0;
}
}
}
const m2 = {
id: 'm2',
actions: {
play(id: string) {
return true;
},
go(n: number) {
return 0;
}
}
}
type MyModule = ??
// should return :
// MyModule = {
// 'm1/down': (id: string) => boolean,
// 'm1/up': (n: number) => number;
// 'm2/play': (id: string) => boolean;
// 'm2/go': (n: number) => number;
// }
Is this possible in typescript?