type Lifecycle = "before" | "after";
type Foo<A, B> = {
[key in Lifecycle]?: (...args: A[]) => B;
};
type Bar = Foobar<[string], void>;
type Baz = Foobar<[number, number], void>;
const example1: Bar = {
after: (str) => { console.log(str); }
const example2: Baz = {
after: (num1, num2) => num1 + num2
};
I'm trying to use generics so that type Baz will work like the "example" objects below, like, the object keys should stay the same but I want to be able to define before/after keys' argument types and their return. The same object keys, but different function parameters and function return.