Can someone help with implementing conditional function typing in an object?
let obj = {
function myfunc (input: string): number;
function myfunc (input: number): string;
myfunc: function (input: string|number):string|number {
...
}
}
I've been getting syntax errors and have tried various methods, none of which seem to work.
Here are a few examples of my attempts:
let obj = {
myfunc (input: string): number;
myfunc (input: number): string;
myfunc: function (input: string|number):string|number {
...
}
}
let obj = {
function myfunc (input: string): number;
function myfunc (input: number): string;
myfunc: function (input: string|number):string|number {
...
}
}
let obj:{
function myfunc (input: string) : number;
function myfunc (input: number) : string;
myfunc: (input: string|number) => number|string
} = {
myfunc: function (input: string|number):string|number {
return ""
}
}