Skip to content
This repository was archived by the owner on Jan 8, 2022. It is now read-only.
This repository was archived by the owner on Jan 8, 2022. It is now read-only.

Unnecessarily strict typings #55

@Lioness100

Description

@Lioness100

Issue description

The following error can be produced with any two collections that have different key or value types. I understand why you shouldn't be able to use two collections with different key types, as the resulting collection will always be empty, however, I don't understand why you can't do two collections with different value types, as values aren't referenced at all in either of the functions below.

For example, if I had a collection of non-discord related data about users (Collection<Snowflake, RandomUserData>), and wanted to only view the data for users who are in a voice channel (VoiceChannel#members is Collection<Snowflake, GuildMember>), I wouldn't be able to.

Code sample

const collection1 = new Collection<string, string>(...);
const collection2 = new Collection<string, number>(...);

collection1.intersect(collection2);
collection1.difference(collection2);

// Argument of type 'Collection<string, number>' is not assignable to parameter of type 'Collection<string, string>'.

@discordjs/collection version

0.3.2

Node.js version

16.6.1

Operating system

Windows

Priority this issue should have

Low (slightly annoying)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions