Skip to content
Latchkey

tsc TS2741: Property 'x' is missing in type but required in type in CI

TS2741 is a structural error: the object you assigned or passed is missing a property that the target type marks as required. It is the most common reason an object literal is not assignable to an interface.

What this error means

tsc fails with "error TS2741: Property 'id' is missing in type '{ name: string; }' but required in type 'User'." naming the absent required property.

tsc
src/seed.ts:2:7 - error TS2741: Property 'id' is missing in type '{ name: string; }' but required
in type 'User'.

2 const u: User = { name: 'Ada' };
        ~

Common causes

The object literal omits a required field

The target interface requires a property the value does not provide, so the value is not assignable.

A required field that should be optional

The interface marks as required a property that callers legitimately omit, so every such value fails.

How to fix it

Add the missing property

  1. Read which required property is missing and on which target type.
  2. Add the property to the object value.
  3. Re-run tsc to confirm the value is now assignable.
src/seed.ts
const u: User = { id: 'u1', name: 'Ada' };

Make the property optional if omission is valid

When callers may legitimately omit the field, mark it optional in the interface rather than forcing a placeholder.

src/types.ts
interface User { id?: string; name: string; }

How to prevent it

  • Keep interfaces aligned with the objects that must satisfy them.
  • Mark genuinely optional fields with ?.
  • Construct objects with the full required shape in factories and seeds.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →