Everything seems to be working well with the code below, except for an error that occurs with the resolve
constant.
const resolve: Resolve Type '(param: "case 1" | "case 2" | "case 3") => boolean | "string" | 1000' is not assignable to type 'Resolve'.(2322)
// Overloads
type Resolve = {
(): false;
(param: 'case 1'): string;
(param: 'case 2'): number;
(param: 'case 3'): true;
};
const resolve: Resolve = (param) => {
switch (param) {
case 'case 1':
return 'string';
case 'case 2':
return 1000;
case 'case 3':
return true;
default:
return false;
}
};
const result = {
first: resolve('case 1'),
second: resolve('case 2'),
third: resolve('case 3'),
none: resolve()
};
Do you have any suggestion on how to fix this issue?