Skip to content

[node] Allow object-mode implementations of write and writev in WritableOptions#25263

Merged
1 commit merged intoDefinitelyTyped:masterfrom
fluggo:master
Apr 30, 2018
Merged

[node] Allow object-mode implementations of write and writev in WritableOptions#25263
1 commit merged intoDefinitelyTyped:masterfrom
fluggo:master

Conversation

@fluggo
Copy link
Copy Markdown
Contributor

@fluggo fluggo commented Apr 24, 2018

Writable's write function accepts chunks of type any to permit object-mode usage. The implementations you can provide to Writable's constructor should do the same.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

If changing an existing definition:

@fluggo
Copy link
Copy Markdown
Contributor Author

fluggo commented Apr 24, 2018

I don't understand what happened here. My changes had nothing to do with the failures found in the test.

@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Apr 24, 2018

@fluggo Thank you for submitting this PR!

🔔 @eps1lon @WilcoBakker @inlined @Alorel @parambirs @tellnes @octo-sniffle @smac89 @Flarna @mwiktorczyk @wwwy3y3 @DeividasBakanas @kjin @alvis @OliverJAsh @Hannes-Magnusson-CK @jkomyno @hoo29 @n-e @ajafff - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@typescript-bot typescript-bot added Popular package This PR affects a popular package (as counted by NPM download counts). The Travis CI build failed labels Apr 24, 2018
@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Apr 24, 2018

@fluggo The Travis CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@fluggo
Copy link
Copy Markdown
Contributor Author

fluggo commented Apr 24, 2018

On my system, the tests fail even on upstream 54a59cd, and in the exact same way as seen in travis-ci.

@fluggo fluggo mentioned this pull request Apr 24, 2018
2 tasks
@fluggo
Copy link
Copy Markdown
Contributor Author

fluggo commented Apr 25, 2018

Blocked on #25271.

Comment thread types/node/index.d.ts
objectMode?: boolean;
write?: (chunk: string | Buffer, encoding: string, callback: Function) => any;
writev?: (chunks: Array<{ chunk: string | Buffer, encoding: string }>, callback: Function) => any;
write?: (chunk: any, encoding: string, callback: Function) => any;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really any here or should this be something like {} to avoid null and undefined?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote "any" to match the definition of write on the stream. The documentation also says <any>; I know of no reason it couldn't be null or undefined on an object-mode stream.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have read here https://nodejs.org/dist/latest/docs/api/stream.html#stream_writable_write_chunk_encoding_callback that null is not allowed in object mode. But you are right the APIs should be symmetric.

@typescript-bot typescript-bot added the Owner Approved A listed owner of this package signed off on the pull request. label Apr 27, 2018
Writable's write function accepts chunks of type any to permit object-mode
usage. The implementations you can provide to Writable's constructor should
do the same.
@typescript-bot
Copy link
Copy Markdown
Contributor

A definition owner has approved this PR ⭐️. A maintainer will merge this PR shortly. If it shouldn't be merged yet, please leave a comment saying so and we'll wait. Thank you for your contribution to DefinitelyTyped!

@ghost ghost merged commit edd9c31 into DefinitelyTyped:master Apr 30, 2018
KSXGitHub pushed a commit to KSXGitHub/DefinitelyTyped that referenced this pull request May 12, 2018
…elyTyped#25263)

Writable's write function accepts chunks of type any to permit object-mode
usage. The implementations you can provide to Writable's constructor should
do the same.
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Owner Approved A listed owner of this package signed off on the pull request. Popular package This PR affects a popular package (as counted by NPM download counts).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants