What does TypeScript infer for T in each of these calls?
Name the type each ^? line points at, and every error TypeScript reports.
function identity<T>(value: T): T { return value;}function pair<T>(first: T, second: T): [T, T] { return [first, second];} const one = identity("hello");// ^?let two = identity("hello");// ^?const three = identity<string | number>(42);// ^?const four = pair(1, 2);// ^?const five = pair(1, "two");Work it out first: the compiler shows every error and type.
The answer
Work out every error TypeScript reports and every type it shows, line by line. Then check.
Checking your sign-in…