Skip to content

Commit

Permalink
fix(build): update to support strictBuiltinIteratorReturn (discordjs#…
Browse files Browse the repository at this point in the history
…10394)

* fix(build): update to support strictBuiltinIteratorReturn

* types: assert Value to be identical to InitialValue

Co-authored-by: René <9092381+Renegade334@users.noreply.github.com>

---------

Co-authored-by: ckohen <chaikohen@gmail.com>
Co-authored-by: René <9092381+Renegade334@users.noreply.github.com>
Co-authored-by: Almeida <github@almeidx.dev>
  • Loading branch information
4 people authored Aug 20, 2024
1 parent 1b1ae2f commit bf83db9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/collection/src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class Collection<Key, Value> extends Map<Key, Value> {
if (amount < 0) return this.last(amount * -1);
amount = Math.min(this.size, amount);
const iter = this.values();
return Array.from({ length: amount }, (): Value => iter.next().value);
return Array.from({ length: amount }, (): Value => iter.next().value!);
}

/**
Expand All @@ -104,7 +104,7 @@ export class Collection<Key, Value> extends Map<Key, Value> {
if (amount < 0) return this.lastKey(amount * -1);
amount = Math.min(this.size, amount);
const iter = this.keys();
return Array.from({ length: amount }, (): Key => iter.next().value);
return Array.from({ length: amount }, (): Key => iter.next().value!);
}

/**
Expand Down Expand Up @@ -512,7 +512,7 @@ export class Collection<Key, Value> extends Map<Key, Value> {
if (thisArg !== undefined) fn = fn.bind(thisArg);
const iter = this.entries();
return Array.from({ length: this.size }, (): NewValue => {
const [key, value] = iter.next().value;
const [key, value] = iter.next().value!;
return fn(value, key, this);
});
}
Expand Down Expand Up @@ -634,7 +634,7 @@ export class Collection<Key, Value> extends Map<Key, Value> {
const iterator = this.entries();
if (initialValue === undefined) {
if (this.size === 0) throw new TypeError('Reduce of empty collection with no initial value');
accumulator = iterator.next().value[1];
accumulator = iterator.next().value![1] as unknown as InitialValue;
} else {
accumulator = initialValue;
}
Expand Down

0 comments on commit bf83db9

Please sign in to comment.