I searched here and haven’t found any way
- To easily assign a type to a class method (
method2: Method
isn’t a class method in pure sense it’s an “instance” (own property) method). - When you override a parent method there’s no easy way to infer type of the child method, so I used
Parameters<>
(and I have extremely complex parameter list (with typed callbacks, etc)). - There’s
satisfies
keyword but I don’t understand how it could be applied to this case
type Method = (n: number) => number;
class A{
method(n: number){
return n;
}
method2: Method = n => n;
}
class B extends A {
method(...[n]: Parameters<A['method']>){
return n;
}
}
Any help how to make optimal DRY (without repeating a long method list in an interface and again in classes) typing would be appreciated.