0Pricing
TypeScript Academy · Lesson

Freshness and Excess Property Checking

Explore why excess properties trigger errors in some contexts.

What Is Freshness?

Freshness is a TypeScript concept where object literals are considered "fresh" at the point of creation. Fresh objects undergo strict excess property checking that widened objects do not.

interface Point { x: number; y: number; }
const p: Point = { x: 1, y: 2, z: 3 }; // Error: 'z' not in Point

Excess Property Checking in Action

When you assign an object literal directly to a typed variable or pass it as a function argument, TypeScript reports extra properties that are not in the target type.

function setPoint(p: { x: number; y: number }) {}
setPoint({ x: 1, y: 2, z: 3 }); // Error: 'z' excess property

All lessons in this course

  1. Type Widening and Narrowing Mechanics
  2. Contextual Typing: Inference from Context
  3. Freshness and Excess Property Checking
  4. const Assertions and as const
← Back to TypeScript Academy