Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(GuildAuditLogsEntry): correct mapped AuditLogChange objects #10438

Merged

Conversation

Renegade334
Copy link
Contributor

@Renegade334 Renegade334 commented Aug 8, 2024

Please describe the changes this PR makes and why it should be merged:

  • The typedefs and .d.ts types for AuditLogChange imply that the old and new parameters are optional, matching the optional old_value and new_value parameters of the APIAuditLogChange object passed into the map function. This wasn't reflected by the previous implementation, where these parameters in the output mapped object were always set, but their value was undefined if the relevant parameter wasn't set in the source object.
    • This change ensures that the old and new parameters are truly optional, and are not set if their source parameter is not set.
  • The .d.ts type for AuditLogChange is now a correctly mapped union type, which means that it's now possible to narrow the object type based on change.key.

Resolves #10437.

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

@Renegade334 Renegade334 requested a review from a team as a code owner August 8, 2024 20:35
Copy link

vercel bot commented Aug 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Aug 20, 2024 9:15am
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Aug 20, 2024 9:15am

@Renegade334 Renegade334 changed the title refactor(GuildAuditLogsEntry): correct mapped AuditLogChange objects fix(GuildAuditLogsEntry): correct mapped AuditLogChange objects Aug 8, 2024
@kodiakhq kodiakhq bot merged commit 45f7e1a into discordjs:main Aug 20, 2024
7 checks passed
@almeidx almeidx added this to the discord.js 14.16 milestone Aug 20, 2024
nyapat pushed a commit to nyapat/discord.js that referenced this pull request Sep 9, 2024
…scordjs#10438)

* refactor(GuildAuditLogsEntry): correct mapped AuditLogChange objects

* test: check union narrowing behaviour of AuditLogChange

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
nyapat pushed a commit to nyapat/discord.js that referenced this pull request Oct 4, 2024
…scordjs#10438)

* refactor(GuildAuditLogsEntry): correct mapped AuditLogChange objects

* test: check union narrowing behaviour of AuditLogChange

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add type safety to interface AuditLogChange
5 participants