I need help creating a mapper for objects that allows TypeScript to recognize the returned type correctly. For example:
type ExampleObject = {
text: string; // this object may have properties of any type
number: number;
};
const object: ExampleObject = {
text: 'asd',
number: 1
};
const object2 = customMapper(object); // the "object" can be any object
// expected type for this scenario
type ExpectedObject = {
text: () => string;
number: () => number;
};
// expected value
object2 ===
{
text: () => 'asd',
number: () => 1
};