@@ -66,7 +66,7 @@ export interface UseAsyncProps<Option extends OptionType> extends TypeaheadCompo
6666 useCache ?: boolean ;
6767}
6868
69- type Cache = Record < string , OptionType [ ] > ;
69+ type Cache < Option extends OptionType > = Record < string , Option [ ] > ;
7070
7171interface DebouncedFunction extends Function {
7272 cancel ( ) : void ;
@@ -96,7 +96,7 @@ export function useAsync<Option extends OptionType>(props: UseAsyncProps<Option>
9696 ...otherProps
9797 } = props ;
9898
99- const cacheRef = useRef < Cache > ( { } ) ;
99+ const cacheRef = useRef < Cache < Option > > ( { } ) ;
100100 const handleSearchDebouncedRef = useRef < DebouncedFunction | null > ( null ) ;
101101 const queryRef = useRef < string > ( props . defaultInputValue || '' ) ;
102102
@@ -179,16 +179,15 @@ export function useAsync<Option extends OptionType>(props: UseAsyncProps<Option>
179179}
180180
181181/* istanbul ignore next */
182- export function withAsync < T extends UseAsyncProps = UseAsyncProps > (
182+ export function withAsync < Option extends OptionType , T extends UseAsyncProps < Option > = UseAsyncProps < Option > > (
183183 Component : ComponentType < T >
184184) {
185185 warn (
186- false ,
187- 'Warning: `withAsync` is deprecated and will be removed in the next ' +
186+ false ,
187+ 'Warning: `withAsync` is deprecated and will be removed in the next ' +
188188 'major version. Use `useAsync` instead.'
189189 ) ;
190-
191- const AsyncTypeahead = forwardRef < Typeahead , T > ( ( props , ref ) => (
190+ const AsyncTypeahead = forwardRef < Typeahead < Option > , T > ( ( props , ref ) => (
192191 < Component { ...props } { ...useAsync ( props ) } ref = { ref } />
193192 ) ) ;
194193
0 commit comments