You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
declareconst$CombinedState: unique symbol// Declare combined state as an union of a symbol index and the template parameter StypeCombinedStateWorks<S>={readonly[$CombinedState]?: undefined}&S;// Try to assign a combined state to a Record<string, unknown> ... success! no compile errors{constcombined: CombinedStateWorks<{a: number}>={a: 2};constrecord: Record<string,unknown>=combined;}// Declare combined state as an union of the interface "EmptyObject" (identical to the inline type above) and the template parameter SinterfaceEmptyObject{readonly[$CombinedState]?: undefined}typeCombinedStateFails<S>=EmptyObject&S;// Try to assign a combined state to a Record<string, unknown> ... fail!{constcombined: CombinedStateFails<{a: number}>={a: 2};// ERROR RIGHT HEREconstrecord: Record<string,unknown>=combined;}
π Actual behavior
Despite CombinedStateFails and CombinedStateWorks being the same type specification (except one uses an interface, one an inline type definition), one fails to case to a Record<string, unknown> and the other succeeds.
π Expected behavior
Both cases should have the same compilation result (success).
This is a problem because recent releases of Redux have refactored their CombinedState type from the first example here to the second, breaking some of my code. I'm not sure what type besides Record<string, unknown> I can use as my parameter type now.
The text was updated successfully, but these errors were encountered:
Bug Report
π Version & Regression Information
Typescript version 4.4.4 (also tested on the nightly v4.6.0-dev.20211105)
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Despite
CombinedStateFails
andCombinedStateWorks
being the same type specification (except one uses an interface, one an inline type definition), one fails to case to aRecord<string, unknown>
and the other succeeds.π Expected behavior
Both cases should have the same compilation result (success).
This is a problem because recent releases of Redux have refactored their
CombinedState
type from the first example here to the second, breaking some of my code. I'm not sure what type besidesRecord<string, unknown>
I can use as my parameter type now.The text was updated successfully, but these errors were encountered: