-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Better TypeScript typing for throws assertions #1956
Conversation
|
||
test('throws', t => { | ||
const err1: Error = t.throws(() => {}); | ||
// t.is(err1.foo, 'foo'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a type exception. I think maybe there's a way to indicate that to tsc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the // @ts-ignore
comment to ignore the below line.
|
||
test('throws', t => { | ||
const err = t.throws<CustomError>(myFunc); | ||
t.is(err.parent.name, 'TypeError'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also include the contents of myFunc
somewhere as it's not that clear where TypeError
comes from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
I've added the Flow typing too. |
Fixes #1893.
I might do Flow tomorrow if I have the time.