-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Description
Search Terms:
AsyncIterableIterator
Code
declare function generatorPipe<A, B, C>(ab: (a: A) => B, bc: (b: B) => C): (a: A) => C
declare function map<A, B>(fn: (p: A) => B): (inputs: Iterable<A>) => AsyncIterableIterator<B>
const foo = generatorPipe(
map( (i: number ) => i + 1),
map( (i: number ) => i + 1),
)Expected behavior:
const foo: (a: Iterable<number>) => AsyncIterableIterator<number>Actual behavior:
TypeScript seems to infer Iterable for AsyncIterableIterator
Argument of type '(inputs: Iterable) => AsyncIterableIterator' is not assignable to parameter of type '(a: Iterable) => Iterable'.
Property '[Symbol.iterator]' is missing in type 'AsyncIterableIterator' but required in type 'Iterable'.ts(2345)
Note, the following works as expected
declare function generatorPipe<A, B, C>(ab: (a: A) => B, bc: (b: B) => C): (a: A) => C
declare function map<A, B>(fn: (p: A) => B): (inputs: Iterable<A>) => IterableIterator<B>
const foo = generatorPipe(
map( (i: number ) => i + 1),
map( (i: number ) => i + 1),
)
const foo = (a: Iterable<number>) => IterableIterator<number>Playground Link:
Playground does not support AsyncIterableIterator
Metadata
Metadata
Assignees
Labels
No labels