Skip to content

Commit

Permalink
feat: 🎸 list all useAsync state props so that TS dont complain
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Dec 17, 2018
1 parent 533e26f commit 7c1b107
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/__stories__/useAsync.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>((resolve) => {
setTimeout(() => {
resolve('RESOLVED');
}, 1000);
});

const Demo = () => {
const {loading, value} = useAsync(fn);
const {loading, value} = useAsync<string>(fn);

return (
<div>
Expand Down
3 changes: 3 additions & 0 deletions src/useAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import {useState, useEffect, useCallback} from 'react';
export type AsyncState<T> =
| {
loading: true;
error?: undefined;
value?: undefined;
}
| {
loading: false;
error: Error;
value?: undefined;
}
| {
loading: false;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7c1b107

Please sign in to comment.