TypeScript Advanced Test

Challenge your knowledge of generics, utility types, narrowing, keyof and exhaustive checks.

6 questions. Choose the best answer for each question, then review every explanation.

Question 1 of 6

1 of 6
Question 1What does the type parameter preserve in this function?
function identity<T>(value: T): T { return value; }
Question 2What does keyof User produce?
interface User { id: number; name: string }
Question 3What does Partial<User> do?
Question 4Which check narrows value from unknown to string?
Question 5What does the never type represent?
Question 6What does readonly enforce on a property?
interface Item { readonly id: number }