Repository navigation
feat(DEP0201): add Duplex.toWeb readableType codemod - #570
FrustratedBoy420 wants to merge 2 commits into
Conversation
Rename the deprecated `type` option passed to `Duplex.toWeb()` to
`readableType` in inline options objects. Resolve `Duplex` from `stream`
and `node:stream` across CommonJS and ESM, including namespace, default,
destructured, and aliased imports. Expand shorthand `{ type }` to
`{ readableType: type }`.
Leave calls unchanged and warn when the options contain both keys,
spreads, computed keys, getters, setters, methods, or duplicate `type`
keys, so runtime behaviour is preserved.
Closes nodejs#559
Assisted-by: Claude Code (claude-opus-5-5)
There was a problem hiding this comment.
could you read and apply rule of https://ai-coding-assistants-policy.openjsf.org/
|
in term of code LGMT ! |
|
Thanks for the review, @AugustinMauroy, and for pointing me to the policy. I've read it and updated the PR description with an AI assistance section. The commit has a |
8a0d1c3 to
1d03bf2
Compare
|
Update: I've rewritten the commit trailer to |
|
Thanks for the review and approval, @AugustinMauroy! |
This comment was marked as spam.
This comment was marked as spam.
|
@brunocroh @JakobJingleheimer this already has an approval from @AugustinMauroy and CI is green. Could one of you give it a second review? Thanks! |
Closes #559
What
Adds a new recipe,
@nodejs/duplex-toweb-readabletype, for DEP0201. The recipe renames the deprecatedtypeoption passed toDuplex.toWeb()toreadableType.import { Duplex } from 'node:stream'; -const pair = Duplex.toWeb(stream, { type: 'bytes' }); +const pair = Duplex.toWeb(stream, { readableType: 'bytes' });How
Duplex.toWebfromstreamandnode:streamwithgetModuleDependenciesandresolveBindingPath. This covers CommonJS and ESM, plus namespace, default, destructured, and aliased imports.{ type }to{ readableType: type }without renaming the variable.'type'becomes'readableType').What it skips (with a warning)
Following the guidance in the issue, the call is left unchanged and a
file:line:columnwarning is printed when the options contain:typeandreadableType, because Node.js usesreadableType ?? typeand removingtypecould change behaviour;typekeys.Options passed as a variable (
Duplex.toWeb(stream, options)) are left unchanged without a warning, because the object may be shared or mutated elsewhere.Tests
9 fixtures: ESM named, ESM namespace, ESM default, CJS aliased destructuring with shorthand, CJS namespace with string keys, TypeScript, already-migrated code (idempotency), conflicting/unsafe options, and unrelated APIs (
Readable.toWeb, a localDuplex, plain objects, a third argument).npm testin the recipe: 9 passedbiome lint: cleannpm run type-check: cleanAI assistance
This PR was written with help from Claude Code (
claude-opus-5-5), following the OpenJS AI Coding Assistants Policy. All commits carry anAssisted-by: Claude Code (claude-opus-5-5)trailer. I take responsibility for this submission.