octet-stream / form-data

Spec-compliant FormData implementation for Node.js
https://www.npmjs.com/package/formdata-node
MIT License
142 stars 17 forks source link

Cannot find name 'ReadableStream'. #33

Closed dynamicbark closed 3 years ago

dynamicbark commented 3 years ago

I wasn't originally having this issue, not sure how it occurred, but whenever I go to run tsc on my project, I get an error from this module. The error I get is below, I've listed how I was able to fix it below the error.

node_modules/formdata-node/@type/File.d.ts:17:26 - error TS2304: Cannot find name 'ReadableStream'.

17     stream(): Readable | ReadableStream | AsyncIterableIterator<any>;
                            ~~~~~~~~~~~~~~

I was able to fix it by changing ReadableStream to NodeJS.ReadableStream in the @type/File.d.ts after I install the module. I would open a PR to fix this but I have no idea what will break by me changing it so instead I'm opening this issue.

octet-stream commented 3 years ago

I was able to fix it by changing ReadableStream to NodeJS.ReadableStream

This ReadableStream was meant to be a WHATWG stream, not Node.js Readable stream. But I guess it does not necessary here, because I only expect any source with [Symbol.asyncIterator] method on it, returned from File#stream() (as long as fetch-blob able to read content from the source it should work, I guess). I'll just remove it.

octet-stream commented 3 years ago

Try the new version https://github.com/octet-stream/form-data/releases/tag/v3.3.1

dynamicbark commented 3 years ago

Just tried it and now my project is compiling and working successfully. Thank you for the quick fix.