0Pricing
TypeScript Academy · Lesson

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); // undefined

All lessons in this course

  1. Why satisfies Exists
  2. satisfies vs Type Annotation
  3. satisfies vs as Assertion
  4. Practical satisfies Patterns
← Back to TypeScript Academy