Collection with TypeScript.
Hello, I'm declaring a collection like in the image below (inside a class constructor), but am getting the following error:
Generic type 'Collection<K, V>' requires 2 type argument(s).

16 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Oh I see, I would be putting objects into that Collection, so the correct way would be:
textCommands: Collection<string, Object>
?Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I do yes, so I could create an interface called Command above it and then pass it in? That's very smart!
that works, thanks!

I do have another issue tho
not realted to collections, do i create a new thing or just rename this one?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Oh, why so, what's the difference between the two?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
oh I see thank you a lot everyone!
really great help <3
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
you can just use
slashCommands = new Collection<string, SlashCommandExport>();
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Did sort of a version of that. BUT, I did create an interface called SlashCommandExport which is kind of a blueprint for an object so
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
yeah i corrected it