Flow: stream$Readable should accept any type in object mode

Created on 28 Jan 2017  路  3Comments  路  Source: facebook/flow

Hi there,

I am using flow in a node project, and when I was extending a readable's stream I got the following error:

image

So I dug into the node's declaration file and I found this:

https://github.com/facebook/flow/blob/master/lib/node.js#L1246

Node's documentation is also wrong, since for push method it says that it only accepts:

Buffer | null | String (see here)

But then when explains how object mode works (see here) it says what it really happens; that you can push any JS value if this mode is enabled

I was wondering what would be the best way to specify this behavior...

IMHO there are 2 alternatives:

  1. Switch it to be a generic type depending on the options, and then have 2 different options types: one with object mode true and the other with false, as this will allow to specify what push accepts based on the options
  2. Simply add any to the types it accepts

Any thoughts?

Accepting PRs Library definitions node

Most helpful comment

Yeah, I'd close this one in favor of the #2010.

All 3 comments

Dupe of #2010?

You are right @philikon, should I close the issue then (I don't know how you are dealing with duplicates)?

Yeah, I'd close this one in favor of the #2010.

Was this page helpful?
0 / 5 - 0 ratings