Complete the code to declare a function overload for a function named combine that takes two numbers and returns a number.
function combine(a: number, b: number): [1];string as return type when inputs are numbers.void.The function combine takes two numbers and returns a number, so the return type should be number.
Complete the code to declare a function overload for combine that takes two strings and returns a string.
function combine(a: string, b: string): [1];number as return type for string inputs.any unnecessarily.The function combine takes two strings and returns a string, so the return type should be string.
Fix the error in the implementation signature of the overloaded function combine.
function combine(a: [1], b: [1]): [1] { if (typeof a === 'string' && typeof b === 'string') { return a + b; } return a + b; }
string or number only, which causes type errors.unknown without type checks.The implementation signature must be compatible with all overloads, so using any for parameters and return type allows handling both strings and numbers.
Fill both blanks to complete the function overloads for combine that accept either two numbers or two strings.
function combine(a: [1], b: [1]): [1]; function combine(a: [2], b: [2]): [2];
any in overload declarations.The first overload takes two numbers and returns a number, the second takes two strings and returns a string.
Fill all three blanks to complete the overloaded function combine with implementation that handles both numbers and strings.
function combine(a: [1], b: [1]): [2]; function combine(a: [3], b: [3]): [3]; function combine(a: any, b: any): any { if (typeof a === 'string' && typeof b === 'string') { return a + b; } return a + b; }
any in overload declarations instead of specific types.The first overload uses number parameters, the second uses string. Both return the type matching their parameters.