C.W.K.
Stream
Quiz · 3 questions

🪄 Type Manipulation — Computing Types from Types

keyof, typeof, indexed access, mapped types, template literals, advanced infer

Level 0Curious
0 XP0/93 lessons0/23 achievements
0/100 XP to next level100 XP to go0% complete

Quiz

01What does keyof { id: number; name: string } give you?
Hint
Hover keyof User in your editor — TypeScript shows you the literal union.
02What's the difference between keyof T and T[keyof T]?
Hint
Try writing both on an interface in your editor and hovering each to see what comes out.
03What does a mapped type { [K in keyof T]: ... } actually do?
Hint
Compare { [K in keyof T]: T[K] } (identity) with { [K in keyof T]?: T[K] } (Partial) — only one character difference, very different result.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.