From 16dd657033d8afac2ffea567b3c8bb27c9b249b6 Mon Sep 17 00:00:00 2001 From: Maxwell Brown Date: Wed, 25 Dec 2024 12:16:54 -0500 Subject: [PATCH] extend IterableIterator instead of Generator (#4190) --- .changeset/polite-crews-march.md | 5 +++++ packages/effect/src/Utils.ts | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changeset/polite-crews-march.md diff --git a/.changeset/polite-crews-march.md b/.changeset/polite-crews-march.md new file mode 100644 index 00000000000..a0af43b7d12 --- /dev/null +++ b/.changeset/polite-crews-march.md @@ -0,0 +1,5 @@ +--- +"effect": patch +--- + +extend `IterableIterator` instead of `Generator` in `SingleShotGen` diff --git a/packages/effect/src/Utils.ts b/packages/effect/src/Utils.ts index 6d2d3464f58..53b297dcc70 100644 --- a/packages/effect/src/Utils.ts +++ b/packages/effect/src/Utils.ts @@ -40,7 +40,7 @@ export type GenKindTypeId = typeof GenKindTypeId export interface GenKind extends Variance { readonly value: Kind - [Symbol.iterator](): Generator, A> + [Symbol.iterator](): IterableIterator, A> } /** @@ -97,7 +97,7 @@ export class GenKindImpl implements GenKind, A> { + [Symbol.iterator](): IterableIterator, A> { return new SingleShotGen, A>(this as any) } } @@ -106,7 +106,7 @@ export class GenKindImpl implements GenKind implements Generator { +export class SingleShotGen implements IterableIterator { private called = false constructor(readonly self: T) {} @@ -147,7 +147,7 @@ export class SingleShotGen implements Generator { /** * @since 2.0.0 */ - [Symbol.iterator](): Generator { + [Symbol.iterator](): IterableIterator { return new SingleShotGen(this.self) } }