const enum Tag {
Friday = 'Friday',
Planning = 'Planing',
}
const test = (tag: Tag, task:/* ??? */): string => {/* some logic */}
If tag
is set to Tag.Friday
, then the function task
should expect a parameter of type (tour: string) => string
If tag
is set to Tag.Planning
, then the function task
should expect a parameter of type (date: Date) => string
I attempted to use function discriminated union and function overloads, but neither was able to infer the type of task
. You can check out my code in the TS Playground