Skip to content

Commit 8163847

Browse files
authored
refactor: IterationResult type's pendingFirst incorrectly inferred false instead of boolean when the source type is a regular async iter (#58)
1 parent f073d90 commit 8163847

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/useAsyncIter/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ const useAsyncIter: {
119119
value?: AsyncIterableSubject<unknown>['value'];
120120
},
121121
initialVal: MaybeFunction<unknown>
122-
): IterationResult<unknown, unknown> => {
122+
): IterationResult<any, any> => {
123123
const rerender = useSimpleRerender();
124124

125-
const stateRef = useRefWithInitialValue<IterationResult<unknown, unknown>>(() => ({
125+
const stateRef = useRefWithInitialValue<IterationResult<any, any>>(() => ({
126126
value: callOrReturn(initialVal) /*as any*/,
127127
pendingFirst: true,
128128
done: false,
@@ -259,11 +259,13 @@ type IterationResult<TVal, TInitVal = undefined> = {
259259
} & (
260260
| (TVal extends AsyncIterableSubject<unknown>
261261
? never
262-
: {
263-
pendingFirst: true;
264-
done: false;
265-
error: undefined;
266-
})
262+
: TVal extends AsyncIterable<unknown>
263+
? {
264+
pendingFirst: true;
265+
done: false;
266+
error: undefined;
267+
}
268+
: never)
267269
| ({
268270
pendingFirst: false;
269271
} & (

0 commit comments

Comments
 (0)