Skip to content

Unexpected excess property error with intersection of index signaturesΒ #51875

Closed

Description

@jcalz

Bug Report

πŸ”Ž Search Terms

index signature, intersection, excess property checking

πŸ•— Version & Regression Information

  • This changed between versions 4.8.0-dev.20220613 and 4.8.0-dev.20220614

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

let x: { [k: string]: { a: 0 } } & { [k: string]: { b: 0 } };

x = { y: { a: 0, b: 0 } } // error!
//               ~~~~  
// Object literal may only specify known properties, 
// and 'b' does not exist in type '{ a: 0; }'

x = { y: { a: 0 } } // error!
//    ~
// Property 'b' is missing in type '{ a: 0; }'

πŸ™ Actual behavior

The object literal { a: 0, b: 0 } is considered to have an excess property of b, but if you remove b then the compiler will complain that b is missing. It's a catch-22!

πŸ™‚ Expected behavior

The object literal { a:0, b: 0 } should be accepted.


This came from this Stack Overflow question. Looks like it started with #49503.

Activity

  1. fatcerberus commented on Dec 13, 2022

    @fatcerberus

    Property b is missing in type { a: 0; }

    Nice.

  2. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions