Question: Consider the following TypeScript generic function: function combine ( first: T , second: U ) : T | U { return { . . .

Consider the following TypeScript generic function:
function combine(first: T, second: U): T | U {
return {...first, ...second };
}
const output = combine({ job: Engineer},{ salary: 50000});
What is the type of output?
Answers:
1. object
2.{{ job: string },{ salary: number }}
3.{ job: string }|{ salary: number }
4. T | U
5. Error: Type T is not assignable to type U.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!