Skip to content
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

Merged
merged 2 commits into from
Sep 16, 2015

Conversation

chbrown
Copy link
Contributor

@chbrown chbrown commented Sep 3, 2015

When a stream.Transform is fed from a stream that has {objectMode: true}, the Stream#_transform(chunk, encoding, callback) method will not be called with chunks that are strings or Buffers.

Simply adding a _transform() variant with chunk: 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.

@vvakame
Copy link
Member

vvakame commented Sep 8, 2015

@jvilk @loyd could you review this PR?

@loyd
Copy link
Contributor

loyd commented Sep 8, 2015

@chbrown The same as _write, write, writev, unshift, and end.

@chbrown
Copy link
Contributor Author

chbrown commented Sep 8, 2015

@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?

@loyd
Copy link
Contributor

loyd commented Sep 8, 2015

@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 any solution.

@chbrown
Copy link
Contributor Author

chbrown commented Sep 8, 2015

@loyd I agree. I've made the rest of the changes. It turns out a few of the chunk: T argument types were already any, e.g., Readable#push. Let me know if I missed any.

@loyd
Copy link
Contributor

loyd commented Sep 9, 2015

@vvakame LGTM

vvakame added a commit that referenced this pull request Sep 16, 2015
Replace Stream#_transform()s with single method with chunk: any
@vvakame vvakame merged commit 9b37801 into DefinitelyTyped:master Sep 16, 2015
@vvakame
Copy link
Member

vvakame commented Sep 16, 2015

@loyd thanks!
@chbrown thanks mate! 👍

@jvilk
Copy link
Contributor

jvilk commented Sep 16, 2015

Thanks for reviewing, @loyd! I was on vacation, but am back now. 😄 I hope we can eventually have better support for typing things as string | Buffer without inconveniencing code writers.

rschmukler added a commit to rschmukler/DefinitelyTyped that referenced this pull request Sep 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants