Can a function wrap
be defined in a way that allows this code to work correctly?:
function wrap<Self>(
creator: (self: Self) => Self
) {}
wrap(self => ({
val: 2,
func(): number {
return self.val;
}
}));
The current TypeScript setup triggers an error at return self.val;
with the message:
Property 'val' does not exist on type '{}'.
It is desired for wrap
to inferred the type of self
to be the same as the return value of the function.