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

refactor: update makeURLSearchParams to accept readonly non-Records #8868

Merged

Conversation

kyranet
Copy link
Member

@kyranet kyranet commented Nov 26, 2022

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

I didn't realize how painful it was to use the utility until I saw #8736 using them extensively. This patch ensures that:

  1. We can pass non-Records:
      declare options: RESTGetAPIApplicationCommandsQuery;
    - makeURLSearchParams(options as Record<string, unknown>);
    + makeURLSearchParams(options);
  2. We can cast types:
      // Expects `RESTGetAPIApplicationCommandsQuery`:
    - makeURLSearchParams({ withLocalizations: true }); // Should be `with_localizations``, doesn't raise type error.
    + makeURLSearchParams<RESTGetAPIApplicationCommandsQuery>({ withLocalizations: true }); // Raises type error due to mismatching types.

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 Nov 26, 2022

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

2 Ignored Deployments
Name Status Preview Updated
discord-js ⬜️ Ignored (Inspect) Nov 27, 2022 at 9:53AM (UTC)
discord-js-guide ⬜️ Ignored (Inspect) Nov 27, 2022 at 9:53AM (UTC)

@kyranet kyranet added this to the rest v1.4 milestone Nov 26, 2022
packages/rest/src/lib/utils/utils.ts Outdated Show resolved Hide resolved
@iCrawl iCrawl merged commit 8376e2d into discordjs:main Nov 28, 2022
@kyranet kyranet deleted the refactor/rest/improved-make-url-search-params branch November 28, 2022 12:07
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.

4 participants