diff --git a/spec/tests/useAsyncIterState.spec.tsx b/spec/tests/useAsyncIterState.spec.tsx index c9141b9..e459b51 100644 --- a/spec/tests/useAsyncIterState.spec.tsx +++ b/spec/tests/useAsyncIterState.spec.tsx @@ -39,7 +39,7 @@ describe('`useAsyncIterState` hook', () => { const yieldPromise1 = iterator1.next(); const yieldPromise2 = iterator2.next(); - await iterator1.return!(); + await iterator1.return(); { const promiseStates = await Promise.all( @@ -51,7 +51,7 @@ describe('`useAsyncIterState` hook', () => { ]); } - await iterator2.return!(); + await iterator2.return(); { const promiseStates = await Promise.all( diff --git a/src/useAsyncIterState/IterableChannel.ts b/src/useAsyncIterState/IterableChannel.ts index 6362c4d..7493210 100644 --- a/src/useAsyncIterState/IterableChannel.ts +++ b/src/useAsyncIterState/IterableChannel.ts @@ -18,7 +18,12 @@ class IterableChannel { this.#nextIteration.resolve({ done: true, value: undefined }); } - iterable = { + iterable: { + [Symbol.asyncIterator](): { + next(): Promise>; + return(): Promise>; + }; + } = { [Symbol.asyncIterator]: () => { const whenIteratorClosed = promiseWithResolvers>(); @@ -33,5 +38,5 @@ class IterableChannel { }, }; }, - } satisfies AsyncIterable; + }; } diff --git a/src/useAsyncIterState/index.ts b/src/useAsyncIterState/index.ts index c489e6c..e870c69 100644 --- a/src/useAsyncIterState/index.ts +++ b/src/useAsyncIterState/index.ts @@ -77,4 +77,4 @@ function useAsyncIterState(): AsyncIterStateResult { * * @see {@link useAsyncIterState `useAsyncIterState`} */ -type AsyncIterStateResult = [AsyncIterable, (newValue: TVal) => void]; +type AsyncIterStateResult = [IterableChannel['iterable'], (newValue: TVal) => void];