Special Sponsor:PromptBuilder— Fast, consistent prompt creation powered by 1,000+ expert templates.
Make your Product visible here.Contact Us

Home/TypeScript Errors/TS2741

TS2741

Property 'X' is missing in type 'Y' but required in type 'Z'

TypeScript TS2741 fires when you create an object that is missing one or more required properties defined in its interface or type. Every non-optional property must be provided when constructing an object of that type.

Why This Happens

You're assigning an object literal or creating an instance that doesn't include all required properties from the target interface or type. Properties without ? are required and must be present.

Code That Triggers TS2741

// TS2741 example
interface User {
  id: number;
  name: string;
  email: string;
}

const user: User = {
  id: 1,
  name: "Alice",
  // missing: email
};
// Error: Property 'email' is missing in type '{ id: number; name: string; }'
// but required in type 'User'

// Also common with React props
interface ButtonProps {
  label: string;
  onClick: () => void;
}
// <Button label="Click" /> // Error: missing 'onClick'

How to Fix TS2741

Option 1: Add the missing required property

const user: User = {
  id: 1,
  name: "Alice",
  email: "alice@example.com", // added
};

Option 2: Make the property optional in the interface

interface User {
  id: number;
  name: string;
  email?: string; // now optional — can be omitted
}

Option 3: Use Partial<T> when building an object incrementally

const partialUser: Partial<User> = { id: 1 }; // all props optional
// Later, assert the full type when you have all properties
const fullUser = { ...partialUser, name: "Alice", email: "a@b.com" } as User;

Frequently Asked Questions — TS2741

What does TS2741 mean?

TS2741 means you created an object that's missing a required property. Every property in an interface without ? must be provided. Add the missing property or make it optional with ?.

How do I make a property optional to fix TS2741?

Add ? after the property name in the interface: email?: string. This makes the property optional and TypeScript won't require it when constructing objects of that type.

TS2741 with React props — how to fix?

Either pass the missing prop to the component, or mark it as optional in the component's Props interface with ?. If the prop has a logical default, add a default parameter value in the component.

What is Partial<T> and when should I use it for TS2741?

Partial<T> creates a type where all properties of T are optional. Use it when building objects incrementally or when you're working with partial updates — like a patch/update operation.

TS2741 when spreading objects — how to fix?

If you spread an object that might not have all required properties, TypeScript reports TS2741. Ensure the spread source has all required props, or use a type assertion after confirming the shape.

Convert JavaScript to TypeScript automatically

Paste your JS code and get type-annotated TypeScript — including fixes for common type errors — in seconds.

Try the converter →

Other TypeScript Errors

From the blog

View all →