satisfies
satisfies checks a value against a type without widening it.
Example
const palette = { red: [255, 0, 0], green: "#0f0" } satisfies Record<string, string | number[]>;
console.log(palette.red.length, palette.green.toUpperCase());Result
3 #0F0
Exercise
Check keeping type.
const x = {} T
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.