Predict Satisfies Operator Output
Predict Output Medium
Question
What does this code print?
Code
type Colors = "red" | "green" | "blue";
const palette = {
primary: "red",
secondary: "green",
} satisfies Record<string, Colors>;
console.log(palette.primary);
console.log(palette.secondary);
Hint
satisfies checks the type but preserves the best inferred type for the object.
Explanation
The satisfies operator verifies that the object matches Record<string, Colors> without widening the types. At runtime, it has no effect. palette.primary is "red" and palette.secondary is "green". Output: red and green.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.