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

Error.cause should have type unknown #50583

Closed
Janpot opened this issue Sep 1, 2022 · 3 comments
Closed

Error.cause should have type unknown #50583

Janpot opened this issue Sep 1, 2022 · 3 comments

Comments

@Janpot
Copy link

Janpot commented Sep 1, 2022

lib Update Request

Configuration Check

My compilation target is ES2022 and my lib is the default.

Missing / Incorrect Definition

cause property on the Error object should have type unknown instead of Error.

Sample Code

The example from MDN:

function makeRSA(p, q) {
  if (!Number.isInteger(p) || !Number.isInteger(q)) {
    throw new Error('RSA key generation requires integer inputs.', {
      cause: { code: 'NonInteger', value: [p, q] },
    });
  }
  if (!areCoprime(p, q)) {
    throw new Error('RSA key generation requires two co-prime integers.', {
      cause: { code: 'NonCoprime', values: [p, q] },
    })
  }
  // rsa algorithm…
}

Documentation Link

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause#providing_structured_data_as_the_error_cause

@MartinJohns
Copy link
Contributor

Good news: It is unknown! At least in the nightly version. This issue is a duplicate of #48098 and it has been fixed already in TypeScript 4.9.

@Janpot
Copy link
Author

Janpot commented Sep 1, 2022

Geat!

edit:

... and thanks ofcourse. Sorry for the duplicate, I swear I searched for it 🙂

@Janpot Janpot closed this as completed Sep 1, 2022
@MartinJohns
Copy link
Contributor

Geat indeed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants