-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get return type of interface function #16372
Comments
You could try it the otherway around, by typing interface S {
weekday: Date;
month: number;
}
type Tokens = {
[K in keyof S]: {
possibleValues: string[],
filter(s: string): S[K],
}
}
const tokens: 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
},
},
};
const parser = {
parseWeekday: ({ weekday, month }: S) => {
},
} Not sure how we're supposed to infer the parameter types of |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
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:
Is that possible?
The text was updated successfully, but these errors were encountered: