Typescript: 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'Interaction<CacheType>'.
See original GitHub issueWhich package is this bug report for?
discord.js
Issue description
Typescript building error:
node_modules/discord.js/typings/index.d.ts:1501:42 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'MappedInteractionTypes<Cached>[T]' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Types of property 'channel' are incompatible.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel' is not assignable to type 'ThreadChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'ThreadChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel' is not assignable to type 'ThreadChannel'.
Type 'DMChannel' is missing the following properties from type 'ThreadChannel': archived, archivedAt, archiveTimestamp, _createdTimestamp, and 35 more.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'ThreadChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'ThreadChannel'.
Type 'NewsChannel' is not assignable to type 'ThreadChannel'.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'ThreadChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'ThreadChannel'.
Type 'NewsChannel' is missing the following properties from type 'ThreadChannel': archived, archivedAt, archiveTimestamp, _createdTimestamp, and 23 more.
1501 } & MessageComponentCollectorOptions<MappedInteractionTypes<Cached>[T]>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/discord.js/typings/index.d.ts:1509:49 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'MappedInteractionTypes<Cached>[T]' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Types of property 'channel' are incompatible.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'ThreadChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel' is not assignable to type 'ThreadChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'ThreadChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'ThreadChannel'.
Type 'NewsChannel' is not assignable to type 'ThreadChannel'.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'ThreadChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'ThreadChannel'.
Type 'NewsChannel' is not assignable to type 'ThreadChannel'.
1509 } & MessageChannelComponentCollectorOptions<MappedInteractionTypes<Cached>[T]>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/discord.js/typings/index.d.ts:1516:35 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'Interaction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'Interaction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'Interaction<CacheType>'.
Types of property 'channel' are incompatible.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'ThreadChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel' is not assignable to type 'ThreadChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'ThreadChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'ThreadChannel'.
Type 'NewsChannel' is not assignable to type 'ThreadChannel'.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'ThreadChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'ThreadChannel'.
Type 'NewsChannel' is not assignable to type 'ThreadChannel'.
1516 InteractionCollectorOptions<MappedInteractionTypes<Cached>[T]>,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/discord.js/typings/index.d.ts:1591:27 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'Interaction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'Interaction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'Interaction<CacheType>'.
Types of property 'channel' are incompatible.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'ThreadChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel' is not assignable to type 'ThreadChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'ThreadChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["cached" | "raw"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'ThreadChannel'.
Type 'NewsChannel' is not assignable to type 'ThreadChannel'.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'ThreadChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'ThreadChannel'.
Type 'NewsChannel' is not assignable to type 'ThreadChannel'.
1591 ): InteractionCollector<MappedInteractionTypes<Cached>[T]>;
Code sample
No response
Package version
discord.js@13.7.0
Node.js version
17.3.0
Operating system
Debian 10
Priority this issue should have
High (immediate attention needed)
Which partials do you have configured?
Not applicable (subpackage bug)
Which gateway intents are you subscribing to?
Not applicable (subpackage bug)
I have tested this issue on a development release
No response
Issue Analytics
- State:
- Created a year ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Bug: Mapped type does not satisfy the constraint it just ...
So my guess is that this is related to the type-indexing, whatever stores the constraint on T here does not store the same...
Read more >TypeScript: Type 'T' does not satisfy the constraint '(...args
In order to instantiate a generic type, say ReturnType<T> , with our type parameter, our type parameter must constrained at least as ...
Read more >Why is my Pick<> failing with "Type does not satisfy the ...
I have a file called ionIcons.ts. It contains a list of var delcarations. export declare var accessibility: string; export declare var…
Read more >Typescript error "does not satisfy the constraint new" when ...
If you get an error when trying to use InstanceType from typegoose as a parameter to a method in typescript make sure you...
Read more >Incorrect, "Type does not satisfy the constraint" error when ...
The following code is in fact valid, compiles and runs fine, and is without error in the TypeScript Playground. However, when R# is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We don’t support running TS without strict mode enabled. And neither should you run it without anyway.
I mean sometime, you still need to add features to old code base, and refactoring everything because one dependency is not compatible is troublesome.
And to add to this problem, it works nice when running with tsnode, only when you want to build with
tsc
it will fail with the above error message. I suspect you have something wrong in your types for this to happens… it doesn’t make sense that astrict
project cannot build in a non strict one.