Skip to content

Commit

Permalink
Typing fixes (#54)
Browse files Browse the repository at this point in the history
- reversePromise(): add return type.
- NftProvider return type: move to React.FC.
  • Loading branch information
bpierre authored May 3, 2021
1 parent 0591982 commit 619f96c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
12 changes: 4 additions & 8 deletions src/core.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ReactNode } from "react"
import type { FC, ReactNode } from "react"
import type {
Address,
Fetcher,
Expand Down Expand Up @@ -69,16 +69,12 @@ const NftContext = createContext<{
fetcher?: Fetcher<unknown> | null
} | null>(null)

function NftProvider({
children,
fetcher,
}: {
const NftProvider: FC<{
children: ReactNode
fetcher?: Fetcher<unknown> | FetcherDeclaration | null
}): JSX.Element {
const normalizedFetcher = normalizeFetcher(fetcher)
}> = function NftProvider({ children, fetcher }) {
return (
<NftContext.Provider value={{ fetcher: normalizedFetcher }}>
<NftContext.Provider value={{ fetcher: normalizeFetcher(fetcher) }}>
{children}
</NftContext.Provider>
)
Expand Down
6 changes: 3 additions & 3 deletions src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ export function promiseAny<T>(promises: Promise<T>[]): Promise<T> {
Promise.all([...promises].map(reversePromise))
) as Promise<T>
}
export function reversePromise(promise: Promise<unknown>) {
return new Promise((resolve, reject) =>
export function reversePromise(promise: Promise<unknown>): Promise<unknown> {
return new Promise((resolve, reject) => {
Promise.resolve(promise).then(reject, resolve)
)
})
}

0 comments on commit 619f96c

Please sign in to comment.