Closed
Description
I've got object that has some function that returns various types. I have another object that is aware of the first object, and I need to know return type of function from first object
Example:
I've got first object like:
const tokens = {
// key below is name of token
month: {
possibleValues: ['jan', 'feb'], // etc...
filter: (monthName: string): number => {
return 12; // will return number 1-12
},
},
weekday: {
possibleValues: ['mon', 'tue'], // etc
filter: (monthName: string): Date => {
return new Date(); // will return Date of weekday
},
},
};
// as seen above - filter of 'month' always returns number and filter of 'weekday' returns Date
const parser: Parser<typeof tokens> {
parseWeekday: ({ weekday, month }) => {
// weekday should be detected to be Date type
// month should be detected to be number type
}
}
Is that possible?