From 7c1b107eb463c04f76548644623015e436cf16d5 Mon Sep 17 00:00:00 2001 From: streamich Date: Mon, 17 Dec 2018 18:37:14 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20list=20all=20useAsync=20?= =?UTF-8?q?state=20props=20so=20that=20TS=20dont=20complain?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__stories__/useAsync.story.tsx | 4 ++-- src/useAsync.ts | 3 +++ yarn.lock | 8 ++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/__stories__/useAsync.story.tsx b/src/__stories__/useAsync.story.tsx index 8fe24b3dc8..8976224116 100644 --- a/src/__stories__/useAsync.story.tsx +++ b/src/__stories__/useAsync.story.tsx @@ -3,14 +3,14 @@ import {storiesOf} from '@storybook/react'; import {useAsync} from '..'; import ShowDocs from '../util/ShowDocs'; -const fn = () => new Promise((resolve) => { +const fn = () => new Promise((resolve) => { setTimeout(() => { resolve('RESOLVED'); }, 1000); }); const Demo = () => { - const {loading, value} = useAsync(fn); + const {loading, value} = useAsync(fn); return (
diff --git a/src/useAsync.ts b/src/useAsync.ts index aa0ecfe180..760bceca17 100644 --- a/src/useAsync.ts +++ b/src/useAsync.ts @@ -3,10 +3,13 @@ import {useState, useEffect, useCallback} from 'react'; export type AsyncState = | { loading: true; + error?: undefined; + value?: undefined; } | { loading: false; error: Error; + value?: undefined; } | { loading: false; diff --git a/yarn.lock b/yarn.lock index bdab4b1837..0096ce12e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9556,10 +9556,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.1.3.tgz#01b70247a6d3c2467f70c45795ef5ea18ce191d5" - integrity sha512-+81MUSyX+BaSo+u2RbozuQk/UWx6hfG0a5gHu4ANEM4sU96XbuIyAB+rWBW1u70c6a5QuZfuYICn3s2UjuHUpA== +typescript@^3.2.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.2.tgz#fe8101c46aa123f8353523ebdcf5730c2ae493e5" + integrity sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg== ua-parser-js@^0.7.18: version "0.7.19"