Skip to content

    ↑↓ move · ⏎ open · esc close

    TS2741

    A required property is missing

    Property 'b' is missing in type '{ a: number; }' but required in type 'Need'.

    The compiler’s own words. Not translated — this is the string you pasted into a search box.

    The object is the right shape as far as it goes — it just does not go far enough. Every property the target requires must be present.

    Reproduction

    type Need = { a: number; b: string }
    
    const x: Need = { a: 1 }

    The build asserts this emits exactly this code.

    Why the compiler says this

    This is the friendliest error in the list, because it names the exact property and both types. It fires where a plain assignability failure would have been vaguer, and it means the compiler recognised what you were building and can see precisely what is absent. Treat it as a checklist rather than a rejection.

    Fixes

    1. 01
      type Need = { a: number; b: string }
      
      const x: Need = { a: 1, b: 'two' }

      Supply it.

    2. 02
      type Need = { a: number; b?: string }
      
      const x: Need = { a: 1 }

      Or make it optional, if it genuinely is. Do this only when a value without `b` is a valid value — not to get past the error.

    Takeaway

    An optional property is a claim about your domain, not a way to quiet the compiler. Adding `?` to silence this error moves the failure to whoever reads the value later.

    Errors