-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace Stream#_transform()s with single method with chunk: any #5658
Replace Stream#_transform()s with single method with chunk: any #5658
Conversation
@chbrown The same as |
@loyd I guess I only wanted to venture as much as I needed for my library to compile — but yes, those suffer the same problem. Would you approve a PR changing them all? |
@chbrown Well. I think, until TS supports default generic type or has strong type inference (like rust or haskell), parameterizing leads to "visual" overhead (it will always need to specify the type explicit) and I am inclined to |
…with `chunk: any`
@loyd I agree. I've made the rest of the changes. It turns out a few of the |
@vvakame LGTM |
Replace Stream#_transform()s with single method with chunk: any
Thanks for reviewing, @loyd! I was on vacation, but am back now. 😄 I hope we can eventually have better support for typing things as |
references DefinitelyTyped#5658, references DefinitelyTyped#5774
When a stream.Transform is fed from a stream that has
{objectMode: true}
, theStream#_transform(chunk, encoding, callback)
method will not be called with chunks that are strings or Buffers.Simply adding a
_transform()
variant withchunk: any
does not satisfy the TypeScript compiler for some reason.I'd prefer type parameterizing the whole
stream.Transform
class with the type of the chunks it will deal with, but this change is smaller, and, I imagine, less contentious.