Change return type of toStream() to Readable
ervinoro opened this issue · 3 comments
It is actually a readable ( https://github.com/westy92/html-pdf-chrome/blob/master/src/CreateResult.ts#L90 ).
Having it typed as Stream means it is error, for example, when using Nest.js StreamableFile:
Argument of type 'Stream' is not assignable to parameter of type 'Readable'.
Type 'Stream' is missing the following properties from type 'Readable': readableAborted, readable, readableDidRead, readableEncoding, and 21 more.
According to the typings, class Readable extends Stream
, therefore Readable
is a Stream
.
Could you please provide a minimal reproducible example?
Every Readable is a Stream, but not every Stream is a Readable. You can look at the example I provided from Nest.js, where the constructor for StreamableFile requires a Readable (for obvious reasons: it needs to read from the stream). It is a type error to pass a Stream to the constructor (because not every Stream is a Readable, and passing a non-readable stream is obviously nonsense). In reality it's unnecessary, because toStream will always return a Readable, therefore typing it as Readable would allow the result to be passed into the StreamableFile constructor without type errors.