Type error with ApplicationCommandType and ContextMenuCommandType

I just upgraded TypeScript and some other things in my package.json and it apparently now thinks that the following code is invalid:
new ContextMenuCommandBuilder()
.setName('...')
.setType(ApplicationCommandType.Message)
// TS2345: Argument of type ApplicationCommandType. Message is not assignable to parameter of type ContextMenuCommandType
new ContextMenuCommandBuilder()
.setName('...')
.setType(ApplicationCommandType.Message)
// TS2345: Argument of type ApplicationCommandType. Message is not assignable to parameter of type ContextMenuCommandType
When checking the types ContextMenuCommandBuilder#setType() requires the type ContextMenuCommandType, which is resolved to ApplicationCommandType.Message | ApplicationCommandType.User. So why are these types not compatible to each other? Is this possibly due to a version mismatch? My versions:
"discord-api-types": "^0.37.101"
"discord.js": "^14.16.3"
"typescript": "^5.6.3"

Node: v22.9.0
"discord-api-types": "^0.37.101"
"discord.js": "^14.16.3"
"typescript": "^5.6.3"

Node: v22.9.0
Thanks in advance.
11 Replies
d.js toolkit
d.js toolkit3mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
NyR
NyR3mo ago
Or you can also use // @ts-expect-error for now, will be fixed in the next version
Meridian
MeridianOP3mo ago
Oh okay, thank you. I missed that while searching. Which version of discord-api-types is used in 14.16.3? 0.37.100?
NyR
NyR3mo ago
Override it to 0.37.101, also no need install discord-api-types separately
Meridian
MeridianOP3mo ago
Alright. But how do I override it without a seperate entry in package.json?
NyR
NyR3mo ago
you have to do it like this
Meridian
MeridianOP3mo ago
Noted. This and restarting the TypeScript service solved it. I guess I can remove the override in the next version?
NyR
NyR3mo ago
Yes
Meridian
MeridianOP3mo ago
Alright. Thank you!
NyR
NyR3mo ago
The fix is already merged, will be available when the next version releases
Meridian
MeridianOP3mo ago
Perfect. Again, thanks for helping out!
Want results from more Discord servers?
Add your server