Open jakebailey opened 1 year ago
:wave: Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of the repro in the issue body running against the nightly TypeScript.
Issue body code block by @jakebailey
:x: Failed: -
Argument of type 'Map' is not assignable to parameter of type 'ReadonlySet | ReadonlyMap'.
Type 'Map' is not assignable to type 'ReadonlyMap'.
Types of property 'forEach' are incompatible.
Type '(callbackfn: (value: number, key: string, map: Map) => void, thisArg?: any) => void' is not assignable to type '(callbackfn: (value: any, key: number, map: ReadonlyMap) => void, thisArg?: any) => void'.
Types of parameters 'callbackfn' and 'callbackfn' are incompatible.
Types of parameters 'key' and 'key' are incompatible.
Type 'string' is not assignable to type 'number'.
Version | Reproduction Outputs |
---|---|
4.8.2, 4.9.3, 5.0.2, 5.1.3, 5.2.2 |
:x: Failed: -
|
Bug Report
π Search Terms
ReadonlyMap ReadonlySet key inference
π Version & Regression Information
β― Playground Link
Playground Link
π» Code
π Actual behavior
The order of the union appears to matter, breaking inference and erroring on valid code. Swapping the union order allows the code to compile.
π Expected behavior
All of this should compile; the union ordering should not matter.