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.
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
- Read which required property is missing and on which target type.
- Add the property to the object value.
- Re-run tsc to confirm the value is now assignable.
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.
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.