Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
TypeScript
/
Advanced types
Why does { [K in keyof M]: { type: K; payload: M[K] } }[keyof M] preserve an event name-p…
from Advanced types
TypeScript 6
advanced
1 min
Why does { [K in keyof M]: { type: K; payload: M[K] } }[keyof M] preserve an event name-payload relationship?
It builds one complete object per key before collecting those objects into a union.
Indexed access validates every payload at runtime.
Mapped types turn the result into a nominal type.
keyof keeps only the first key in M.
Check
Ask AI about this kata
Report an error
previous kata
Which conditional tests whether a union T as a whole is assignable to U?
Quiz
next kata
What does this program print?
Predict the output
A new version is available
Reload