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

chore: improve ExpectionAssertion type in Brittle TypeScript definitions #517

Merged
merged 1 commit into from
Mar 14, 2024

Conversation

achou11
Copy link
Member

@achou11 achou11 commented Mar 14, 2024

Noticed a couple of minor issues:

  • types were not handling providing a promise (note, not a function returning a promise) as the first argument
  • was noticing some misleading "unnecessary awaits" warnings in my editor, even though the provided function was async. narrowed it down to needing to adjust the order of the overload so that it was ordered from most specific to least specific (i.e. () => Promise<unknown> is a subset of () => unknown)

@achou11 achou11 requested a review from EvanHahn March 14, 2024 15:23
@@ -9,15 +9,28 @@ declare module 'brittle' {
type AnyErrorConstructor = new () => Error

interface ExceptionAssertion {
(
fn: Promise<unknown> | (() => Promise<unknown>),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically fn is kind of a misleading parameter name in the case of providing a promise, but didn't think that creating another overload made sense vs using a union

types/brittle.d.ts Show resolved Hide resolved
types/brittle.d.ts Show resolved Hide resolved
@EvanHahn
Copy link
Contributor

Thanks for fixing this!

@achou11 achou11 merged commit 5b1d635 into main Mar 14, 2024
4 checks passed
@achou11 achou11 deleted the ac/fix-brittle-exception-assertion branch March 14, 2024 17:05
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.

2 participants