satisfies vs as Assertion
Why satisfies is safer than casting with as.
What as Does
The as assertion tells the compiler to trust you about a type. It does not check that the value actually fits, it just overrides the inferred type.
const value = { color: "red" } as { color: string; size: number };
// No error even though size is missing!
console.log(value.color);as Bypasses Safety
Because as skips validation, it can hide real bugs. The object above is missing size, yet TypeScript stays silent.
type Config = { color: string; size: number };
const broken = { color: "red" } as Config;
// broken.size is typed number but is actually undefined at runtime
console.log(broken.size); // undefinedAll lessons in this course
- Why satisfies Exists
- satisfies vs Type Annotation
- satisfies vs as Assertion
- Practical satisfies Patterns