From d720451078c552c326d67b39d8f8ce676f221136 Mon Sep 17 00:00:00 2001 From: Matthisk Heimensen Date: Thu, 21 Mar 2019 12:04:57 +0100 Subject: [PATCH] Updated TypeScript definitions By exporting the `AsyncState` interface we allow users of the library to pass around the `AsyncState` without them having to duplicate the type in their own codebase. With the current type definitions it is not possible to type the parameter of a function to be of type `AsyncState`. --- src/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index e731f000..da35d33e 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -3,7 +3,7 @@ import * as React from "react" type AsyncChildren = ((state: AsyncState) => React.ReactNode) | React.ReactNode type PromiseFn = (props: object) => Promise -interface AsyncOptions { +export interface AsyncOptions { promise?: Promise promiseFn?: (props: object, controller: AbortController) => Promise deferFn?: (args: any[], props: object, controller: AbortController) => Promise @@ -19,7 +19,7 @@ interface AsyncProps extends AsyncOptions { children?: AsyncChildren } -interface AsyncState { +export interface AsyncState { data?: T error?: Error initialValue?: T