Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add infer helpers for Event<Payload> and Unit<Value> #434

Merged
merged 1 commit into from
Dec 17, 2020
Merged

Add infer helpers for Event<Payload> and Unit<Value> #434

merged 1 commit into from
Dec 17, 2020

Conversation

rymarchikbot
Copy link
Contributor

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

@rymarchikbot
Copy link
Contributor Author

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.

None yet

2 participants