TS2741Semantic Error
Since TS 3.2

Fix TS2741: Property Is Missing but Required

Learn why TypeScript throws TS2741 when an object, a return value or a JSX element misses exactly one required property, and how to fix it properly.

error TS2741: Property 'X' is missing in type 'Y' but required in type 'Z'

What This Error Means

TypeScript error TS2741 means a value is missing exactly one property that its target type marks as required. The compiler lines up the two shapes, finds a single gap, and names it:

const profile: UserProfile = { id: "u_1842", email: "ada@example.com" }
//    ~~~~~~~
// Property 'displayName' is missing in type '{ id: string; email: string; }'
// but required in type 'UserProfile'.

This is structural typing at work. TypeScript does not care that your object was written by hand and UserProfile was declared in another file — it only asks whether every required property of the target is present in the source. One absent property is enough to reject the assignment, because any code that later reads profile.displayName would get undefined at runtime while the type promises a string.

The count of missing properties decides which code you see. One missing property is TS2741; two to five are listed by name as TS2739; from six onwards the compiler truncates the list and reports TS2740. The position matters too: for variable initialisers, return statements and JSX attributes the missing-property sentence is the headline, while for function arguments the headline stays TS2345 and this sentence appears indented beneath it. Same check, same fixes — only the report changes.

Common Causes

1. An Object Literal Written Before the Interface Grew a Field

By far the most common trigger: someone adds a required property to an interface, and every literal that was complete yesterday is now one field short.

interface UserProfile {
  id: string
  email: string
  displayName: string
}
 
// ❌ Broken
const profile: UserProfile = { id: "u_1842", email: "ada@example.com" }
//    ~~~~~~~
// Error: Property 'displayName' is missing in type '{ id: string; email: string; }'
// but required in type 'UserProfile'. (TS2741)
// ✅ Fixed — supply the property with a real value
const profile: UserProfile = {
  id: "u_1842",
  email: "ada@example.com",
  displayName: "Ada Lovelace",
}

If the field can legitimately be absent, say so in the type instead of inventing a placeholder. A separate DraftProfile with displayName?: string keeps the optionality where it belongs rather than loosening UserProfile for everyone.

2. A React Component Rendered Without a Required Prop

In JSX the attributes you write are checked against the props type, so a forgotten prop produces TS2741 with the element name underlined.

interface AvatarProps {
  src: string
  alt: string
}
 
function Avatar({ src, alt }: AvatarProps) {
  return <img src={src} alt={alt} />
}
 
export function ProfileHeader() {
  // ❌ Broken
  return <Avatar src="/ada.png" />
  //      ~~~~~~
  // Error: Property 'alt' is missing in type '{ src: string; }'
  // but required in type 'AvatarProps'. (TS2741)
}
// ✅ Fixed — pass the prop
export function ProfileHeader() {
  return <Avatar src="/ada.png" alt="Ada Lovelace" />
}

Note that the source type in the message, { src: string; }, is the object the JSX attributes form — which is why the fix is always "write the attribute", never "change the component", unless the prop really should be optional.

3. A Function Returning a Partially Built Object

A function annotated with a return type is checked against that type at every return. Mapping a database row or an API payload to a domain object is where this bites most often.

interface UserProfile {
  id: string
  email: string
  displayName: string
}
 
interface DbRow {
  id: string
  email: string
  display_name: string | null
}
 
// ❌ Broken
function toProfile(row: DbRow): UserProfile {
  return { id: row.id, email: row.email }
  //     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  // Error: Property 'displayName' is missing in type '{ id: string; email: string; }'
  // but required in type 'UserProfile'. (TS2741)
}
// ✅ Fixed — spread sensible defaults, then override with the row's values
const DEFAULT_PROFILE: UserProfile = {
  id: "",
  email: "",
  displayName: "Anonymous",
}
 
function toProfile(row: DbRow): UserProfile {
  return {
    ...DEFAULT_PROFILE,
    id: row.id,
    email: row.email,
    displayName: row.display_name ?? row.email,
  }
}

The defaults object is itself typed UserProfile, so when the interface grows another field the error moves to DEFAULT_PROFILE — one place to fix instead of every mapper.

4. A Library Prop That Became Required After an Upgrade

The same error appears out of nowhere after npm update, because a component you render gained a required prop. The message names a prop you have never heard of.

interface GridManager {
  refresh: () => void
}
 
// `manager` became required in the major version you just installed
interface DataGridProps {
  rows: string[]
  manager: GridManager
}
 
function DataGrid({ rows, manager }: DataGridProps) {
  return <ul onClick={manager.refresh}>{rows.map((row) => <li key={row}>{row}</li>)}</ul>
}
 
export function OrdersPanel({ rows }: { rows: string[] }) {
  // ❌ Broken
  return <DataGrid rows={rows} />
  //      ~~~~~~~~
  // Error: Property 'manager' is missing in type '{ rows: string[]; }'
  // but required in type 'DataGridProps'. (TS2741)
}
// ✅ Fixed — construct the object the new version asks for
const gridManager: GridManager = { refresh: () => undefined }
 
export function OrdersPanel({ rows }: { rows: string[] }) {
  return <DataGrid rows={rows} manager={gridManager} />
}

Read the library's changelog before you reach for a workaround. Retyping your wrapper's props as Partial<DataGridProps> makes your file compile while the child still reads manager.refresh at runtime — the crash simply moves out of the compiler and into the browser.

How to Fix It

  1. Supply the property the message names. The error gives you the property, the source shape and the target type. In most cases the gap is real and the honest fix is a real value — compute it, read it from the data you already have, or thread it through from the caller.

  2. Mark it optional at the type if it truly can be absent. Change displayName: string to displayName?: string and handle undefined where the value is read. For React props, pair the question mark with a default inside the component so callers do not have to pass placeholders.

  3. Build incomplete values as Partial<T> and convert in one checked step. While an object is still being assembled, type it Partial<UserProfile>; when it is complete, pass it through a function that validates and returns a real UserProfile. That keeps "half-built" out of the type that the rest of your code trusts.

  4. Spread a typed defaults object. { ...DEFAULT_PROFILE, ...overrides } gives every literal the required properties and moves future errors to a single declaration instead of scattering them across every call site.

  5. Do not silence it with a cast. raw as UserProfile compiles happily and then hands you undefined the first time anything reads profile.displayName. If the value genuinely comes from an untrusted boundary, validate it there and keep the type honest everywhere else — that way the next required property you add produces this error again, which is precisely what you want.

FAQ

What causes TypeScript error TS2741?

TS2741 fires when a value is assigned to a type that requires a property the value does not have, and exactly one property is missing. TypeScript compares shapes structurally, so it makes no difference whether the two types look related or were declared in the same file — only whether every required property is present. The error landed in TypeScript 3.2, which split the old catch-all "type is not assignable" report into this friendlier, property-specific wording. The usual sources are object literals written before an interface grew a field, JSX elements missing a required prop, and functions returning a partially built object.

How do I fix TS2741 when passing props to a React component?

Pass the prop that the message names, with a real value: the source type in the error ({ src: string; }) is literally the set of attributes you wrote, so the fix lives at the call site. If the prop is genuinely optional for some call sites, mark it optional in the props interface and give it a default inside the component:

function Avatar({ src, alt = "" }: { src: string; alt?: string }) {
  return <img src={src} alt={alt} />
}

What you should not do is retype the props as Partial<AvatarProps> or cast the props object. The component still reads alt at runtime; all you have changed is who finds out that it is missing.

What is the difference between TS2741, TS2739 and TS2322?

TS2741 and TS2739 are the same structural check reported at different levels of detail: one missing property gives you TS2741, two to five are listed by name as TS2739, and more than five truncate into TS2740. TS2322 is the general "Type 'X' is not assignable to type 'Y'" error that takes over whenever the mismatch is something other than a plain missing property — a property with the wrong type, an incompatible function signature, a union that does not fit. There is also a positional rule worth knowing: for function arguments the headline is always TS2345, with Property 'displayName' is missing in type … indented beneath it as the explanation. Whichever code you see, the cure is the same — provide the property, map between the shapes, or make the property optional in the type.

Related Errors

Practice This

Put your understanding to the test with these related challenges.

Or browse all TypeScript practice challenges to keep sharpening your type-level skills.

Related Concepts

Share this reference

Become a TypeScript Pro

Track your progress through 200+ hands-on challenges. Free, sign in with GitHub.

Or start solving right away: explore all TypeScript challenges