-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
Description
What happened
Records with object values that would otherwise be compatible are not because of toJS. I've noticed this when fields only differ by optionality.
How to reproduce
import { RecordOf } from 'immutable';
interface Id {}
type A = RecordOf<{ id: Id }>;
type B = RecordOf<{ id?: Id }>;
const a: A = null as any;
const b: B = a;
Results in the error
Type 'A' is not assignable to type 'B'.
Type 'A' is not assignable to type 'Record<{ id?: Id | undefined; }>'.
The types of 'set(...).toJS().id' are incompatible between these types.
Type 'unknown' is not assignable to type 'Id | undefined'.
I think this happens due to the workaround for circular types where objects become unknown. Honestly, I think the new types are more trouble than they're worth and would prefer the 4.1 types.
Reactions are currently unavailable