You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I guess the way defs are compiled is too modern but that's fine, it's solvable.
incorrect type defs
The current def for asyncIterator.d.ts is:
/** * the implementer that does all the heavy works */declareclassReadableStreamAsyncIterableIteratorImpl<R,TReturn>implementsAsyncIterator<R>{
#private;constructor(reader: ReadableStreamDefaultReader<R>,preventCancel: boolean);next(): Promise<IteratorResult<R,undefined>>;return(value?: TReturn): Promise<IteratorReturnResult<TReturn>>;}declareconstimplementSymbol: unique symbol;/** * declare `ReadableStreamAsyncIterableIterator` interaface */interfaceReadableStreamAsyncIterableIterator<R,TReturn>extendsReadableStreamAsyncIterator<R>{[implementSymbol]: ReadableStreamAsyncIterableIteratorImpl<R,TReturn>;}exportinterfaceReadableStreamIteratorOptions{preventCancel?: boolean;}/** * Get an async iterable iterator from a readable stream * @param readableStream * @param readableStreamIteratorOptions * @returns */exportdeclarefunctionasyncIterator<R,TReturn>(readableStream: ReadableStream<R>,{ preventCancel }?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterableIterator<R,TReturn>;export{};
This results in:
forawait(constchunkofasyncIterator(res.body)){}
Type 'ReadableStreamAsyncIterableIterator<Uint8Array, unknown>' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.ts(2504)
This is because the interface doesn't define an asyncIterator, it has this funny implementSybol instead. Simply doing:
interfaceReadableStreamAsyncIterableIterator<R,TReturn>extendsReadableStreamAsyncIterator<R>{[Symbol.asyncIterator](): ReadableStreamAsyncIterableIteratorImpl<R,TReturn>;// Or more acceptable by eslint (@typescript-eslint/method-signature-style):// [Symbol.asyncIterator]: () => ReadableStreamAsyncIterableIteratorImpl<R, TReturn>}
Fixes the issue.
Is there a reason you defined an anonymous symbol that Typescript isn't aware of?:
Hi thanks for this package. I have two TS errors using the Ponyfill.
moduleResolution: "Node"
(solvable)The most common resolution to use but the defs can't be found with it. Solved by changing to:
or
I guess the way defs are compiled is too modern but that's fine, it's solvable.
The current def for
asyncIterator.d.ts
is:This results in:
This is because the interface doesn't define an
asyncIterator
, it has this funnyimplementSybol
instead. Simply doing:Fixes the issue.
Is there a reason you defined an anonymous symbol that Typescript isn't aware of?:
readable-stream/src/core/asyncIterator.ts
Line 87 in 5802d75
The text was updated successfully, but these errors were encountered: