Skip to content

Commit

Permalink
fix(types): changed callback signature on waitFor to match old types
Browse files Browse the repository at this point in the history
  • Loading branch information
mpeyper committed Dec 23, 2020
1 parent 5471a34 commit 1ea2afe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Expand Up @@ -8,7 +8,8 @@
"import/no-unresolved": "off",
"react-hooks/rules-of-hooks": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-unnecessary-condition": "off"
"@typescript-eslint/no-unnecessary-condition": "off",
"@typescript-eslint/no-invalid-void-type": "off"
},
"parserOptions": {
"project": ["./tsconfig.json", "./test/tsconfig.json"]
Expand Down
6 changes: 3 additions & 3 deletions src/asyncUtils.ts
Expand Up @@ -42,14 +42,14 @@ function asyncUtils(addResolver: (callback: () => void) => void) {
await nextUpdatePromise
}

const waitFor = async <T>(
callback: () => T | Promise<T>,
const waitFor = async (
callback: () => boolean | void,
{ interval, timeout, suppressErrors = true }: WaitOptions = {}
) => {
const checkResult = () => {
try {
const callbackResult = callback()
return callbackResult || callbackResult === undefined
return callbackResult ?? callbackResult === undefined
} catch (error: unknown) {
if (!suppressErrors) {
throw error as Error
Expand Down

0 comments on commit 1ea2afe

Please sign in to comment.