Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

TypeScript TS2741: Property is missing in type but required

TS2741 means the target type requires a property your value lacks. Fix the interface, the conditional spread, or the builder that dropped it.

~5 min readTypeScript
#TypeScript#Compiler Errors#Types#Debugging
A TypeScript object crate with one required slot empty, a cyan compiler gate and an amber interface card beside it

Introduction & Quick Summary

text
error TS2741: Property 'email' is missing in type '{ id: number; name: string; }' but required in type 'User'.

TS2741 means the target type has a required property that the value you assigned does not carry. It is not a type-inference failure and not a syntax problem: TypeScript resolved both sides, compared their members, and found one required member absent from the source.

The three facts that decide the fix:

  • Is the property genuinely required? If a user object can legitimately exist without email, the target interface is wrong, not the value.
  • Is the value built incrementally? Objects assembled with conditional spreads lose required members, because the spread operand widens to { email?: string } or false.
  • Is the target a mapped or generic type? Pick, Omit, Partial and Required change which members are required, and the error names the mapped result, not User.
Symptom in the messageReal causeFirst check
One property namedLiteral object short of a required fieldThe interface declaration
Property is optional in your headPartial not applied, or another User importThe resolved type via hover
Comes from a spreadConditional spread produced an optional memberThe spread operand type
Appears in a generic functionConstraint requires more than the defaultThe constraint on T
Appears only in CIexactOptionalPropertyTypes or a second tsconfigThe build config

Core Mechanics, Signatures & Reproducible Setup

TypeScript checks assignability structurally. { id: number; name: string } is assignable to a type only when every required member of the target exists in the source with a compatible type. TS2741 is the "present but incomplete" branch of that check; TS2739 covers two or more missing members, TS2353 covers excess properties in a fresh object literal, and TS2322 wraps the same mismatch when it happens through an assignment.

Reproduce it in a file with strict enabled:

ts
interface User { id: number; name: string; email: string; } const draft = { id: 1, name: "Ada" }; const user: User = draft; // error TS2741: Property 'email' is missing in type // '{ id: number; name: string; }' but required in type 'User'.

The check is not limited to declarations. Function arguments, return values and generic instantiations all produce the same code:

ts
function save(user: User) {} save({ id: 1, name: "Ada" }); // TS2741 function makeUser(): User { return { id: 1, name: "Ada" }; // TS2741 }

The minimal correct version depends on intent, not on the compiler:

ts
interface User { id: number; name: string; email?: string; // optional when absence is legal } const draft: User = { id: 1, name: "Ada" }; // ok

To inspect what the compiler actually resolved, hover the target type in an editor that uses the project's TypeScript version, or print it:

ts
type Debug = User; declare const probe: Debug; // hover `probe` in the editor: id: number; name: string; email: string

A second User declared in another module is the most common reason a property "looks present". Import one canonical type and re-export it rather than redeclaring it.

Key Comparison Table

Error codeMeaningTypical trigger
TS2741One required property missingPartial object literal
TS2739Several required properties missingEmpty or unrelated object
TS2322Value not assignable to targetVariables, not fresh literals
TS2353Excess property in fresh literalTypo or stale field
TS2551Property does not exist, did you meanMisspelled optional field
TS18048Value possibly undefinedstrictNullChecks on access
FixWhen it is correctCost
Make the field optional email?:Absence is a valid stateConsumers must narrow
Supply the fieldThe value is genuinely incompleteExtra mapping code
Use Partial<User>Update payloads, patchesLoss of required guarantees
Use Required<User>Enforce complete inputThrows on optional sources
satisfies UserCheck without wideningNeeds TS 4.9+
Type assertion as UserOnly after a runtime checkSilences the compiler

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

Case 1: Conditional spread drops a required member

ts
interface Payload { id: string; role: string } const isAdmin = false; const payload: Payload = { id: "u1", ...(isAdmin && { role: "admin" }), }; // TS2741: Property 'role' is missing ...

The spread of false contributes nothing, and TypeScript models the resulting object as having role?: string | undefined, which cannot satisfy a required role. Use an always-object operand:

ts
const payload: Payload = { id: "u1", ...(isAdmin ? { role: "admin" } : {}), };

Case 2: Function argument with a partial patch

ts
function updateUser(id: string, patch: Partial<User>) {} updateUser("u1", { email: "a@b.c" }); // ok updateUser("u1", { id: 2 }); // ok, id is optional here

Partial<T> maps every member to optional, which removes TS2741 at the call site but pushes the check into the function body, where patch.email is now string | undefined. Keep the required/optional split explicit instead of applying Partial to whole domain types:

ts
type UserPatch = Partial<Pick<User, "name" | "email">>;

Case 3: Nested objects report the innermost property

ts
interface Address { city: string; zip: string } interface Customer { id: string; address: Address } const c: Customer = { id: "c1", address: { city: "Busan" } }; // TS2741: Property 'zip' is missing ... but required in type 'Address'

Read the type named at the end of the message. It points at the nested interface, so the fix belongs in the nested literal, not in Customer.

Case 4: implements with an optional interface member

ts
interface Named { name: string; nickname?: string } class Person implements Named { name = "Ada"; }

This compiles: implements checks the instance type, and an optional member may be absent. If the class must expose the property for reflection or serialization, declare it explicitly:

ts
class Person implements Named { name = "Ada"; nickname: string | undefined; }

With exactOptionalPropertyTypes the two forms differ: nickname?: string does not accept undefined as a value, while nickname: string | undefined does.

Case 5: Discriminated unions built step by step

ts
type Event = | { kind: "click"; x: number; y: number } | { kind: "key"; code: string }; const e: Event = { kind: "click", x: 10 }; // TS2741 (and TS2322): property 'y' is missing

Partial construction of a union member is always rejected, because the object must match one member exactly. Build with a factory that returns the complete member, or use a builder whose final step returns the union:

ts
function click(x: number, y: number): Event { return { kind: "click", x, y }; }

Case 6: satisfies for config objects

ts
type Config = { retries: number; timeoutMs: number }; const config = { retries: 3, timeoutMs: 5_000, verbose: true, } satisfies Config;

satisfies validates the literal against Config while keeping the narrow inferred type, so config.verbose remains accessible. Using : Config here would reject the extra key with TS2353 and remove verbose from the type. If a required key depends on the environment, compute it before the literal rather than adding it conditionally.

Re-exported types drifting apart.

ts
// src/types.ts export interface User { id: number; name: string; email: string } // src/api/types.ts (stale copy) export interface User { id: number; name: string }

A value typed by the first User fails against the second. Collapse duplicates into one module and re-export:

ts
export type { User } from "../types";

Common Compilation/Runtime Mistakes & Version Gotchas

  • strictNullChecks off masks the error. Without it, missing members widen to undefined-bearing optional shapes in some inference paths, so the error appears only after enabling strict. Enable it before fixing interfaces, or the fixes will be wrong.
  • exactOptionalPropertyTypes (TS 4.4+) distinguishes email?: string from email: string | undefined. A patch object that sets email: undefined compiles under the default and fails under this flag.
  • satisfies requires TS 4.9+. On older compilers the operator is a syntax error, not a type error, so a CI using a pinned old version fails differently than the editor.
  • Declaration files override source. If @types/* or a local .d.ts augments the interface with a required member, the error appears with no visible change in your file. Search for declare module and interface User before editing the literal.
  • Omit on a union collapses the union. Omit<A | B, "kind"> distributes poorly and can require members that only one branch had; wrap it in a distributive conditional type when the target is a union.
  • Enum and literal widening. let role = "admin" widens to string and fails against role: "admin"; use const or as const. This is reported as TS2322 at the assignment and TS2741 once wrapped in an object.

When the two shapes come from different services, paste both JSON responses into the JSON formatter and compare the key sets with the diff tool before deciding which field is genuinely required. For a reviewable normalization query over existing rows, the SQL formatter keeps the migration readable.

Primary references: Object Types covers optional and required members, and the strict family documents strictNullChecks and exactOptionalPropertyTypes as separate switches.

Official references

primary documentation

The TypeScript documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit TypeScript work — they run entirely in this browser tab, so nothing you paste leaves your device.

All TypeScript guides

More in TypeScript

All TypeScript guides

The guides filed next to this one in TypeScript, in library order.