Skip to content

fix(stream-transform): accept options after handler in types - #507

Open
JaylinZhou88 wants to merge 1 commit into
adaltas:masterfrom
JaylinZhou88:fix/stream-transform-handler-options-types
Open

JaylinZhou88 wants to merge 1 commit into
adaltas:masterfrom
JaylinZhou88:fix/stream-transform-handler-options-types

Conversation

@JaylinZhou88

Copy link
Copy Markdown

transform(handler, options) works in JavaScript, including the stream-pipe recipe, but TypeScript rejects the options object as a callback. The same mismatch affects transform(records, handler, options) in the callback and promise samples.

Add overloads for options after the handler, with and without input records, retaining the optional completion callback. Synchronize the CJS and browser declaration copies. Runtime behavior is unchanged.

Related to #348; the original report does not specify whether it used TypeScript, so this addresses the independently reproduced declaration mismatch rather than claiming to resolve every possible cause of that report.

Validation on Windows, Node 24.19.0:

  • The two new cases fail TypeScript checking against the original declarations and pass with this change.
  • tsc --noEmit: passed for packages/stream-transform.
  • Mocha package tests excluding test/samples.js: 68 passed, including both new behavior tests.
  • All 11 sample programs passed when run individually.
  • ESLint, Prettier, and git diff --check: passed for the change.

The unmodified package test command encounters existing Windows harness issues: cmd.exe preserves the single quotes around the Mocha glob, and test/samples.js constructs a Windows path from URL.pathname. The equivalent checks above avoid those harness problems; the harness itself is unchanged.

AI disclosure: OpenAI Codex prepared this patch, reviewed the diff, and executed the local validation. This contribution is submitted on behalf of the account owner; it does not claim independent human code review.

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.

1 participant