From 619f96c0ff42f6e733b8e6632228cc910bb29cff Mon Sep 17 00:00:00 2001 From: Pierre Bertet Date: Mon, 3 May 2021 17:38:06 +0100 Subject: [PATCH] Typing fixes (#54) - reversePromise(): add return type. - NftProvider return type: move to React.FC. --- src/core.tsx | 12 ++++-------- src/utils.tsx | 6 +++--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/core.tsx b/src/core.tsx index 19475cc..dae9b87 100644 --- a/src/core.tsx +++ b/src/core.tsx @@ -1,4 +1,4 @@ -import type { ReactNode } from "react" +import type { FC, ReactNode } from "react" import type { Address, Fetcher, @@ -69,16 +69,12 @@ const NftContext = createContext<{ fetcher?: Fetcher | null } | null>(null) -function NftProvider({ - children, - fetcher, -}: { +const NftProvider: FC<{ children: ReactNode fetcher?: Fetcher | FetcherDeclaration | null -}): JSX.Element { - const normalizedFetcher = normalizeFetcher(fetcher) +}> = function NftProvider({ children, fetcher }) { return ( - + {children} ) diff --git a/src/utils.tsx b/src/utils.tsx index f01332d..2d644c2 100644 --- a/src/utils.tsx +++ b/src/utils.tsx @@ -221,8 +221,8 @@ export function promiseAny(promises: Promise[]): Promise { Promise.all([...promises].map(reversePromise)) ) as Promise } -export function reversePromise(promise: Promise) { - return new Promise((resolve, reject) => +export function reversePromise(promise: Promise): Promise { + return new Promise((resolve, reject) => { Promise.resolve(promise).then(reject, resolve) - ) + }) }