Skip to content
Preptima
mediumConceptCodingMidSeniorStaff

You pass an object with extra properties to something typed to accept fewer. When does TypeScript complain, and when does it not?

TypeScript allows extra properties under structural typing, but excess property checking rejects extra fields on fresh object literals. Assign the same object to a variable first and the extra fields usually pass, which can leak undeclared fields into API responses.

5 min readUpdated 2026-08-15Target archetype: Big Tech, Enterprise Captive, Product Startup

Answer

Short answer

TypeScript complains about extra properties only in excess property checking, mainly for fresh object literals assigned to a narrower type. Once the object flows through a variable, structural typing allows the extra fields because the required shape is present. Use explicit DTO construction when extra fields must not escape.

Was this answer helpful?

Likely follow-ups

  • What does satisfies check that a type annotation does not, and when would you choose each?
  • A spread of two objects is assigned to a narrow type and no error appears. Why not?
  • How does excess property checking behave when the target is a union of object types?
  • Where would you put a test that fails when a newly added database column starts appearing in an API response?

Related questions

Further reading