Open calrsom opened 7 years ago
I see now that this was added in Node 8; I'm not sure how flow handles versions, so maybe this isn't quite a bug.
For the Uint8Array
, but object-mode streams have been around since node v0.9.4. It's definitely something that should be addressed.
This affects multiple method definitions of Stream classes - push
, write
etc are all defined as Buffer | string
which causes problems in object mode streams where 'any' is valid.
I've got a ((someUint8Array: any): Buffer) cast in some test code, and while diagnosing something else I overrode my path to grab a particular Node version, v8.14.1-linux-x64. I got a
TypeError: Invalid data, chunk must be a string or buffer, not object
I too thought that streams switched to accept Uint8Array at version 8, but try a require("child_process").spawn("ls").stdin.write(new Uint8Array(0))
to see for yourself. My 10.14.2 version handles it fine, though.
stream$Writable.write
chunk
argument should includeUint8Array
and can take any non-null value for object-mode streams according to Node documentation.https://github.com/facebook/flow/blob/5c9deb498ca0b523243a8fda40160333f1f23277/lib/node.js#L1439
See: https://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback;