面试题答案
一键面试function handleMixedType(input: MixedType): string | number {
if (typeof input ==='string') {
return input.charAt(0).toUpperCase() + input.slice(1);
} else if (typeof input === 'number') {
return input * 2;
} else if ('value' in input) {
return input.value.length;
}
throw new Error('Unsupported type');
}