cerebral / overmind

Overmind - Frictionless state management
https://overmindjs.org
MIT License
1.58k stars 95 forks source link

Wrong return typing of pipe operator #518

Open WendtOle opened 3 years ago

WendtOle commented 3 years ago

Hi,

an operator only consisting of a pipe like the following:

export const positiveFeedback = pipe(() => Promise.resolve({ success: true }));

has for some reason NOT a type like: () => Promise<{success: true}>, but INSTEAD following type: () => Promise<Promise<{success: true}>> which isn't really possible.

I created a minimal example in codesandbox demonstrating the problem. In src/App/App.tsx you can find the following:

const fails: () => Promise<{ success: boolean }> =
   actions.demo.positiveFeedback;

const works: () => Promise<Promise<{ success: boolean }>> =
   actions.demo.positiveFeedback;

const workaround: () => Promise<{ success: boolean }> = async () =>
   await actions.demo.positiveFeedback();
arturjzapater commented 3 years ago

@christianalfoni , I don't know how you handle contributions (I looked but couldn't find a contributing guide anywhere), but I'd be happy to have a look at this issue, if you want.