Skip to content

TypeScript: use unknown to represent error #1874

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

Merged
merged 1 commit into from
Feb 7, 2019

Conversation

OliverJAsh
Copy link
Contributor

@OliverJAsh OliverJAsh commented Feb 6, 2019

WIP.

unknown makes more sense because an error can be any type—we don't know what the type will be.

Currently this would give a type error:

const reportMyError = (error: unknown) => {
  Raven.captureException(error, {})
};

This fixes that.

There are probably other usages of Error that we should replace with unknown. I don't have the time to consider this right now, but I hope to come back to this PR. At the very least, this PR can act as an issue.


Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

@kamilogorek kamilogorek merged commit b0cabe5 into getsentry:master Feb 7, 2019
@kamilogorek
Copy link
Contributor

Thanks!

@chuchuva
Copy link

chuchuva commented Jul 5, 2019

This breaks builds if you use TypeScript 2 :(

Cannot find name 'unknown'.

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

Successfully merging this pull request may close these issues.

3 participants