Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Dec 17, 2020

No description provided.

@netlify
Copy link

netlify bot commented Dec 17, 2020

👷 Deploy request for effector-docs pending review.
Visit the deploys page to approve it

🔨 Explore the source changes: d75343f

@ghost
Copy link
Author

ghost commented Dec 17, 2020

with new UnitValue<T> we can now simplify some other types

export type UnitValue<T> = T extends Unit<infer V> ? V : never
export type StoreValue<T> = UnitValue<T>
export type EventPayload<T> = UnitValue<T>
export type EffectParams<FX extends Effect<any, any, any>> = UnitValue<FX>
export type EffectResult<FX extends Effect<any, any, any>> = UnitValue<FX['doneData']>
export type EffectError<FX extends Effect<any, any, any>> = UnitValue<FX['failData']>

@zerobias
Copy link
Member

Cool, thanks! 👍

@zerobias zerobias merged commit df8f5a5 into effector:master Dec 17, 2020
@zerobias
Copy link
Member

with new UnitValue<T> we can now simplify some other types

export type UnitValue<T> = T extends Unit<infer V> ? V : never
export type StoreValue<T> = UnitValue<T>
export type EventPayload<T> = UnitValue<T>
export type EffectParams<FX extends Effect<any, any, any>> = UnitValue<FX>
export type EffectResult<FX extends Effect<any, any, any>> = UnitValue<FX['doneData']>
export type EffectError<FX extends Effect<any, any, any>> = UnitValue<FX['failData']>

I found that StoreValue should throw type error when used with events, so this is not an alias, as we previously thought

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant