mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 13:03:31 +01:00
types(Collection): union types on intersect and difference (#7196)
This commit is contained in:
@@ -629,8 +629,8 @@ export class Collection<K, V> extends Map<K, V> {
|
|||||||
*
|
*
|
||||||
* @param other The other Collection to filter against
|
* @param other The other Collection to filter against
|
||||||
*/
|
*/
|
||||||
public intersect(other: Collection<K, V>) {
|
public intersect<T>(other: Collection<K, T>): Collection<K, T> {
|
||||||
const coll = new this.constructor[Symbol.species]<K, V>();
|
const coll = new this.constructor[Symbol.species]<K, T>();
|
||||||
for (const [k, v] of other) {
|
for (const [k, v] of other) {
|
||||||
if (this.has(k)) coll.set(k, v);
|
if (this.has(k)) coll.set(k, v);
|
||||||
}
|
}
|
||||||
@@ -642,8 +642,8 @@ export class Collection<K, V> extends Map<K, V> {
|
|||||||
*
|
*
|
||||||
* @param other The other Collection to filter against
|
* @param other The other Collection to filter against
|
||||||
*/
|
*/
|
||||||
public difference(other: Collection<K, V>) {
|
public difference<T>(other: Collection<K, T>): Collection<K, V | T> {
|
||||||
const coll = new this.constructor[Symbol.species]<K, V>();
|
const coll = new this.constructor[Symbol.species]<K, V | T>();
|
||||||
for (const [k, v] of other) {
|
for (const [k, v] of other) {
|
||||||
if (!this.has(k)) coll.set(k, v);
|
if (!this.has(k)) coll.set(k, v);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user