Skip to content

Commit 97c0ae4

Browse files
committed
fix: type unionWith equivalence over elements of either input
1 parent d105ecd commit 97c0ae4

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎.changeset/array-union-empty-dedupe.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"effect": patch
33
---
44

5-
Fix `Array.union`, `Array.unionWith` and `Chunk.union` keeping duplicates from the non-empty side when the other input is empty.
5+
Fix `Array.union`, `Array.unionWith` and `Chunk.union` keeping duplicates from the non-empty side when the other input is empty. The `Array.unionWith` equivalence is now typed to receive elements from either input.

‎packages/effect/src/Array.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3279,19 +3279,22 @@ const hashBucketsHas = (buckets: HashBuckets, value: unknown): boolean => {
32793279
export const unionWith: {
32803280
<S extends Iterable<any>, T extends Iterable<any>>(
32813281
that: T,
3282-
isEquivalent: (self: ReadonlyArray.Infer<S>, that: ReadonlyArray.Infer<T>) => boolean
3282+
isEquivalent: (
3283+
self: ReadonlyArray.Infer<S> | ReadonlyArray.Infer<T>,
3284+
that: ReadonlyArray.Infer<S> | ReadonlyArray.Infer<T>
3285+
) => boolean
32833286
): (self: S) => ReadonlyArray.OrNonEmpty<S, T, ReadonlyArray.Infer<S> | ReadonlyArray.Infer<T>>
32843287
<A, B>(
32853288
self: NonEmptyReadonlyArray<A>,
32863289
that: Iterable<B>,
3287-
isEquivalent: (self: A, that: B) => boolean
3290+
isEquivalent: (self: A | B, that: A | B) => boolean
32883291
): NonEmptyArray<A | B>
32893292
<A, B>(
32903293
self: Iterable<A>,
32913294
that: NonEmptyReadonlyArray<B>,
3292-
isEquivalent: (self: A, that: B) => boolean
3295+
isEquivalent: (self: A | B, that: A | B) => boolean
32933296
): NonEmptyArray<A | B>
3294-
<A, B>(self: Iterable<A>, that: Iterable<B>, isEquivalent: (self: A, that: B) => boolean): Array<A | B>
3297+
<A, B>(self: Iterable<A>, that: Iterable<B>, isEquivalent: (self: A | B, that: A | B) => boolean): Array<A | B>
32953298
} = dual(
32963299
3,
32973300
<A>(self: Iterable<A>, that: Iterable<A>, isEquivalent: (self: A, that: A) => boolean): Array<A> =>

0 commit comments

Comments
 (0)