-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Labels
Description
Hi, I'm getting the following error
Argument of type '() => Generator<string, void, string>' is not assignable to parameter of type '(setCancelHandler: (onCancel?: (() => void) | undefined, onCancelError?: ((err: Error) => void) | undefined) => void) => IterableIterator<any>'.
Type 'Generator<string, void, string>' is not assignable to type 'IterableIterator<any>'.
Types of property 'next' are incompatible.
Type '(...args: [] | [string]) => IteratorResult<string, void>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<any, any>'.
Types of parameters 'args' and 'args' are incompatible.
Type '[] | [undefined]' is not assignable to type '[] | [string]'.
Type '[undefined]' is not assignable to type '[] | [string]'.
Type '[undefined]' is not assignable to type '[string]'.
Type 'undefined' is not assignable to type 'string'.ts(2345)
using
const [a, setA] = useState('');
useAsyncEffect(function*() {
const value: string = yield "foobars";
setA(value);
}, []);
which seems to be caused by
result = generator.next(result.value);
because TNext is undefined by default
Iterator<T, TReturn = any, TNext = undefined>