openai-node
openai-node copied to clipboard
Remove unnecessary web-streams-polyfill polluting global namespace
Confirm this is a Node library issue and not an underlying OpenAI API issue
- [X] This is an issue with the Node library
Describe the bug
The web-streams-polyfill package has a TypeScript bug where it pollutes the global namespace and misdefines [Symbol.asyncIterator] as a property rather than a method:
https://github.com/MattiasBuelens/web-streams-polyfill/blob/master/dist/types/ts3.6/polyfill.d.ts#L26
vs.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator/@@asyncIterator
This causes subtle typing bugs downstream. Furthermore, ReadableStream is now supported in the LTS version of Node, so the polyfill is no longer necessary:
https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream
To Reproduce
Create an interface that extends both ReadableStream and AsyncGenerator after importing the SDK:
import OpenAI from "openai";
interface IterableReadableStreamInterface<T> extends ReadableStream<T>, AsyncGenerator<T> {}
Code snippets
No response
OS
macOS
Node version
18
Library version
4.24.1
I will also file a bug on web-streams-polyfill