Skip to content

Commit

Permalink
fix(types): More tightly scoping PromiseLike change (#1871 by @kav)
Browse files Browse the repository at this point in the history
  • Loading branch information
kav authored Feb 6, 2022
1 parent 108537f commit 6095151
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/mobx-state-tree/__tests__/core/async.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function testCoffeeTodo(
done: () => void,
generator: (
self: any
) => (str: string) => Generator<PromiseLike<any>, string | void | undefined, undefined>,
) => (str: string) => Generator<Promise<any>, string | void | undefined, undefined>,
shouldError: boolean,
resultValue: string | undefined,
producedCoffees: any[]
Expand Down
6 changes: 3 additions & 3 deletions packages/mobx-state-tree/src/core/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
/**
* @hidden
*/
export type FlowReturn<R> = R extends PromiseLike<infer T> ? T : R
export type FlowReturn<R> = R extends Promise<infer T> ? T : R

/**
* See [asynchronous actions](concepts/async-actions.md).
Expand All @@ -19,7 +19,7 @@ export type FlowReturn<R> = R extends PromiseLike<infer T> ? T : R
*/
export function flow<R, Args extends any[]>(
generator: (...args: Args) => Generator<PromiseLike<any>, R, any>
): (...args: Args) => PromiseLike<FlowReturn<R>> {
): (...args: Args) => Promise<FlowReturn<R>> {
return createFlowSpawner(generator.name, generator) as any
}

Expand Down Expand Up @@ -56,7 +56,7 @@ export function castFlowReturn<T>(val: T): T {
* }))
* ```
*/
export function toGeneratorFunction<R, Args extends any[]>(p: (...args: Args) => PromiseLike<R>) {
export function toGeneratorFunction<R, Args extends any[]>(p: (...args: Args) => Promise<R>) {
return function* (...args: Args) {
return (yield p(...args)) as R
}
Expand Down

0 comments on commit 6095151

Please sign in to comment.