I am looking to define an interface with the following structure:
interface CheckNActSetup<D, C> {
defs: (event: Event) => D,
context: (defs: D) => C;
exec: (context: C) => any[];
when: ((context: C) => boolean)[]; }
and implement it using a class method:
class Test {
register<C>(item: CheckNActSetup<C>) {
}
}
When I attempt to use the method as shown below:
let x = new Test();
x.register({
context: e => ({ value: "A" }),
exec: context => context.value
})
I encounter an issue where the 'context' parameter in the 'exec' property is unknown. My goal is for the compiler to infer that the context type is: { value: string }
To achieve this without adding (e: Event), my question is:
How can I determine the proper context variable type without explicitly specifying (e: Event)?</p>