Consider the code snippet below.
class MyClass {
method1(arg1: string, arg2: number, arg3: number) {}
method2(arg1: string, arg2: number, arg3: number) {}
}
I want to abstract out the argument types
arg1: string, arg2: number, arg3: number
for reuse.Although not functional, the example below illustrates my intention.
interface MyClassMethodArgs {
arg1: string;
arg2: number;
arg3: number;
}
interface MyClass {
// How can I represent "arg1: string, arg2: number, arg3: number" as MyClassMethodArgs?
method1(arg1: string, arg2: number, arg3: number): void;
method2(arg1: string, arg2: number, arg3: number): void;
}
class MyClassImpl implements MyClass {
// How can I avoid repeating the type definitions of MyClass here?
method1(arg1, arg2, arg3) {}
method2(arg1, arg2, arg3) {}
}