Skip to content

types(ClientEventTypes): use Events as keys#11121

Open
Pavel-Boyazov wants to merge 6 commits intodiscordjs:mainfrom
Pavel-Boyazov:events-typing
Open

types(ClientEventTypes): use Events as keys#11121
Pavel-Boyazov wants to merge 6 commits intodiscordjs:mainfrom
Pavel-Boyazov:events-typing

Conversation

@Pavel-Boyazov
Copy link
Contributor

@Pavel-Boyazov Pavel-Boyazov commented Sep 29, 2025

Please describe the changes this PR makes and why it should be merged:
Allow to use native Events as key for ClientEventTypes (for examle ClientEventTypes[Events] instead of ClientEventTypes[keyof ClientEventTypes])

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

@vercel
Copy link

vercel bot commented Sep 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
discord-js Skipped Skipped Feb 10, 2026 1:22pm
discord-js-guide Skipped Skipped Feb 10, 2026 1:22pm

Request Review

Jiralite
Jiralite previously approved these changes Sep 29, 2025
@Jiralite Jiralite dismissed their stale review September 29, 2025 10:13

Awaiting tests.

Copy link
Member

@Jiralite Jiralite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index.test-d.ts is full of errors due to this change.

It seems this stops strings from being used. Unsure if this is desired. @vladfrangu, any ideas?

@github-project-automation github-project-automation bot moved this from Todo to Review in Progress in discord.js Sep 29, 2025
@Jiralite Jiralite added this to the discord.js 15.0.0 milestone Sep 29, 2025
@Pavel-Boyazov
Copy link
Contributor Author

Pavel-Boyazov commented Sep 29, 2025

I agree that removing the ability to use strings directly is a bad idea. But I would also like to add compatibility of the type with the Events enum, since in fact they are completely identical.

@Pavel-Boyazov
Copy link
Contributor Author

As I see it, it comes down to the async_event_emitter's typing. I would like to understand more precisely what can and should be changed there in order to keep support for raw strings

@Pavel-Boyazov
Copy link
Contributor Author

Pavel-Boyazov commented Sep 29, 2025

Another problem. voiceServerUpdate event not exists in ClientEventTypes

@vladfrangu
Copy link
Member

Unsure if this is desired

I wouldn't want this to break normal strings, so if it does... I am -1 on this

@almeidx almeidx requested review from almeidx and removed request for almeidx December 17, 2025 19:01
@vercel vercel bot temporarily deployed to Preview – discord-js-guide February 4, 2026 01:19 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js February 4, 2026 01:19 Inactive
@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

A TypeScript type definition update to the ClientEventTypes interface that adds a constraint extending Record<Events, any[]>. This modification bounds the interface's event keys to the Events union while maintaining existing event mappings.

Changes

Cohort / File(s) Summary
Type Constraint Update
packages/discord.js/typings/index.d.ts
ClientEventTypes interface now extends Record<Events, any[]> to enforce event key constraints within the type system.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: updating ClientEventTypes to use Events as keys, which is the core modification in the changeset.
Description check ✅ Passed The description clearly explains the purpose of the change (enabling ClientEventTypes[Events] usage) and is directly related to the typings modification in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ccae83 and 30fe737.

📒 Files selected for processing (1)
  • packages/discord.js/typings/index.d.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Tests

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/discord.js/typings/index.d.ts (1)

5461-5577: ⚠️ Potential issue | 🟠 Major

Add missing voiceServerUpdate to ClientEventTypes interface.

VoiceServerUpdate is defined in the Events enum but has no corresponding entry in ClientEventTypes. With extends Record<Events, any[]>, any missing event key defaults to any[], breaking type safety. Add the typed entry to preserve strict event handling.

Proposed fix
   voiceChannelEffectSend: [voiceChannelEffect: VoiceChannelEffect];
+  voiceServerUpdate: [data: GatewayVoiceServerUpdateDispatchData];
   voiceStateUpdate: [oldState: VoiceState, newState: VoiceState];
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ccae83 and 30fe737.

📒 Files selected for processing (1)
  • packages/discord.js/typings/index.d.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Tests

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@vercel vercel bot temporarily deployed to Preview – discord-js February 10, 2026 13:22 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide February 10, 2026 13:22 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Review in Progress

Development

Successfully merging this pull request may close these issues.

4 participants