Skip to content

Property 'X' is missing in type 'Y'

Error message

                Property is missing in type
              

Quick summary

You assigned an object to a typed variable, but the object is missing one or more required properties declared in the interface.

Why this happens

  • Forgot to include a required property in the object

  • The interface was updated but the object wasn't

  • Confusing required and optional properties

  • Partial data from an API that doesn't match the full interface

Minimal example

✗ Broken code
interface User { id: number; name: string; email: string; }
const user: User = { id: 1, name: "Alice" }; // missing email
✓ Fixed code
interface User { id: number; name: string; email: string; }
const user: User = { id: 1, name: "Alice", email: "alice@test.com" };

Add the missing email property to satisfy the interface.

How to diagnose

  • Compare the object's properties against the interface definition

  • Check which properties are required (no ?) vs optional (with ?)

  • Look at the error message — it names the missing property

How to fix

  • Add the missing required property to the object

  • Make the property optional in the interface (add ?)

  • Use Partial<T> if all properties should be optional

  • Use a type assertion if you know the property will be added later

How to prevent

  • Keep interfaces and their usages in sync

  • Use Partial<T> for update/patch operations

  • Validate API responses with runtime checks

Related Resources

← Back to language