retryExchange: TS error: Type 'Error' is not assignable to type 'boolean'. ts(2345) #1464
Answered
by
kitten
frederikhors
asked this question in
Q&A
-
Using your usage example here for const retryOptions: {
initialDelayMs: number;
maxDelayMs: number;
randomDelay: boolean;
maxNumberAttempts: number;
retryIf: (err: CombinedError) => Error;
}
Argument of type '{ initialDelayMs: number; maxDelayMs: number; randomDelay: boolean; maxNumberAttempts: number; retryIf: (err: CombinedError) => Error; }' is not assignable to parameter of type 'RetryExchangeOptions'.
The types returned by 'retryIf(...)' are incompatible between these types.
Type 'Error' is not assignable to type 'boolean'.ts(2345) using it like this: const retryOptions = {
initialDelayMs: 1000,
maxDelayMs: 15000,
randomDelay: true,
maxNumberAttempts: 2,
retryIf: (err: CombinedError): boolean => err && err.networkError,
} Am I wrong? |
Beta Was this translation helpful? Give feedback.
Answered by
kitten
Mar 18, 2021
Replies: 1 comment 2 replies
-
It's because you typed this as |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
JoviDeCroock
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's because you typed this as
retryIf: (err: CombinedError) => Error
but it expects a boolean return value. By the way, you likely don't want to duplicate types for larger objects like this and instead either rely on inference or the package's option type.