-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
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.
RyanCavanaugh
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue