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: remove usage of mixin on error classes #10128

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

almeidx
Copy link
Member

@almeidx almeidx commented Feb 13, 2024

Please describe the changes this PR makes and why it should be merged:
Removed the internal mixin function DiscordjsErrorMixin in order to provide better documentation
https://discord.js.org/docs/packages/discord.js/14.14.1/DiscordjsError:Class

image

Status and versioning classification:

@almeidx almeidx requested a review from a team as a code owner February 13, 2024 11:35
Copy link

vercel bot commented Feb 13, 2024

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

2 Ignored Deployments
Name Status Preview Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Feb 13, 2024 11:35am
discord-js-guide ⬜️ Ignored (Inspect) Feb 13, 2024 11:35am

@kodiakhq kodiakhq bot merged commit f48cb2a into main Feb 13, 2024
7 checks passed
@kodiakhq kodiakhq bot deleted the refactor/djs-error-types branch February 13, 2024 11:54
@ssilve1989
Copy link

ssilve1989 commented May 15, 2024

Why did the constructor become private on the typings? A private constructor would imply some other way of creating the object, via some static method, but the internal code still creates it via new. This change to making the constructor private breaks matching on instance type with tools like ts-pattern.

Ex.

    match(error)
      .with(
        P.instanceOf(DiscordjsError),
        ({ code }) => code === DiscordjsErrorCodes.InteractionCollectorError,
        () => { /* some handler code */ }
      )

now breaks with

Argument of type 'typeof DiscordjsError' is not assignable to parameter of type 'AnyConstructor'.
Cannot assign a 'private' constructor type to a 'public' constructor type.

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.

5 participants