[node] buffer: allow ArrayBuffer | string to be passed to Buffer.from#72097
Conversation
|
@sapphi-red Thank you for submitting this PR! This is a live comment that I will keep updated. 1 package in this PRCode ReviewsBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged. You can test the changes of this PR in the Playground. Status
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 72097,
"author": "sapphi-red",
"headCommitOid": "6668d64060ff17a592887ce42dd70ad9fc028e13",
"mergeBaseOid": "515f950351b890f8c45bbfcc793cdc9598da67e8",
"lastPushDate": "2025-03-03T05:21:45.000Z",
"lastActivityDate": "2025-04-25T06:11:16.000Z",
"mergeOfferDate": "2025-04-25T05:53:56.000Z",
"mergeRequestDate": "2025-04-25T06:11:16.000Z",
"mergeRequestUser": "sapphi-red",
"hasMergeConflict": false,
"isFirstContribution": false,
"tooManyFiles": false,
"hugeChange": false,
"popularityLevel": "Critical",
"pkgInfo": [
{
"name": "node",
"kind": "edit",
"files": [
{
"path": "types/node/buffer.buffer.d.ts",
"kind": "definition"
},
{
"path": "types/node/test/buffer.ts",
"kind": "test"
},
{
"path": "types/node/ts5.6/buffer.buffer.d.ts",
"kind": "definition"
},
{
"path": "types/node/v18/buffer.buffer.d.ts",
"kind": "definition"
},
{
"path": "types/node/v18/test/buffer.ts",
"kind": "test"
},
{
"path": "types/node/v18/ts5.6/buffer.buffer.d.ts",
"kind": "definition"
},
{
"path": "types/node/v20/buffer.buffer.d.ts",
"kind": "definition"
},
{
"path": "types/node/v20/test/buffer.ts",
"kind": "test"
},
{
"path": "types/node/v20/ts5.6/buffer.buffer.d.ts",
"kind": "definition"
}
],
"owners": [
"Microsoft",
"jkomyno",
"alvis",
"r3nya",
"btoueg",
"smac89",
"touffy",
"DeividasBakanas",
"eyqs",
"Hannes-Magnusson-CK",
"hoo29",
"kjin",
"ajafff",
"islishude",
"mwiktorczyk",
"mohsen1",
"galkin",
"parambirs",
"eps1lon",
"ThomasdenH",
"WilcoBakker",
"wwwy3y3",
"samuela",
"kuehlein",
"bhongy",
"chyzwar",
"trivikr",
"yoursunny",
"qwelias",
"ExE-Boss",
"peterblazejewicz",
"addaleax",
"victorperin",
"NodeJS",
"LinusU",
"wafuwafu13",
"mcollina",
"Semigradsky"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Critical"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "jakebailey",
"date": "2025-04-25T05:53:15.000Z",
"isMaintainer": true
},
{
"type": "approved",
"reviewer": "Renegade334",
"date": "2025-04-25T04:24:01.000Z",
"isMaintainer": false
}
],
"mainBotCommentID": 2693307815,
"ciResult": "pass"
} |
|
🔔 @microsoft @jkomyno @alvis @r3nya @btoueg @smac89 @Touffy @DeividasBakanas @eyqs @Hannes-Magnusson-CK @hoo29 @kjin @ajafff @islishude @mwiktorczyk @mohsen1 @galkin @parambirs @eps1lon @ThomasdenH @WilcoBakker @wwwy3y3 @samuela @kuehlein @bhongy @chyzwar @trivikr @yoursunny @qwelias @ExE-Boss @peterblazejewicz @addaleax @victorperin @nodejs @LinusU @wafuwafu13 @mcollina @Semigradsky — please review this PR in the next few days. Be sure to explicitly select |
|
I pushed a commit because it didn't fix the case I wanted to 😅 |
|
By the way, it seems this test fails. const a = null as unknown as Uint8Array<SharedArrayBuffer>;
// $ExpectType Buffer || Buffer<SharedArrayBuffer>
Buffer.from(a); // returns Buffer<ArrayBuffer> |
|
@Renegade334 Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
There is some confusion here. Passing an array buffer view (ie. a typed array) to the constructor methods will copy the contents into a new |
Renegade334
left a comment
There was a problem hiding this comment.
You will need to add an equivalent signature to ts5.6/buffer.buffer.d.ts (the only difference being a return type of Buffer rather than Buffer<...>, as these declarations predate the type parameter)
Oh, I see. Thanks for correcting! |
|
@Renegade334 Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
|
Re-ping @microsoft, @jkomyno, @alvis, @r3nya, @btoueg, @smac89, @Touffy, @DeividasBakanas, @eyqs, @Hannes-Magnusson-CK, @hoo29, @kjin, @ajafff, @islishude, @mwiktorczyk, @mohsen1, @galkin, @parambirs, @eps1lon, @ThomasdenH, @WilcoBakker, @wwwy3y3, @samuela, @kuehlein, @bhongy, @chyzwar, @trivikr, @yoursunny, @qwelias, @ExE-Boss, @peterblazejewicz, @addaleax, @victorperin, @nodejs, @LinusU, @wafuwafu13, @mcollina, @Semigradsky: This PR has been out for over a week, yet I haven't seen any reviews. Could someone please give it some attention? Thanks! |
|
It has been more than two weeks and this PR still has no reviews. I'll bump it to the DT maintainer queue. Thank you for your patience, @sapphi-red. (Ping @microsoft, @jkomyno, @alvis, @r3nya, @btoueg, @smac89, @Touffy, @DeividasBakanas, @eyqs, @Hannes-Magnusson-CK, @hoo29, @kjin, @ajafff, @islishude, @mwiktorczyk, @mohsen1, @galkin, @parambirs, @eps1lon, @ThomasdenH, @WilcoBakker, @wwwy3y3, @samuela, @kuehlein, @bhongy, @chyzwar, @trivikr, @yoursunny, @qwelias, @ExE-Boss, @peterblazejewicz, @addaleax, @victorperin, @nodejs, @LinusU, @wafuwafu13, @mcollina, @Semigradsky.) |
|
@sapphi-red: Everything looks good here. I am ready to merge this PR (at 6668d64) on your behalf whenever you think it's ready. If you'd like that to happen, please post a comment saying:
and I'll merge this PR almost instantly. Thanks for helping out! ❤️ (@microsoft, @jkomyno, @alvis, @r3nya, @btoueg, @smac89, @Touffy, @DeividasBakanas, @eyqs, @Hannes-Magnusson-CK, @hoo29, @kjin, @ajafff, @islishude, @mwiktorczyk, @mohsen1, @galkin, @parambirs, @eps1lon, @ThomasdenH, @WilcoBakker, @wwwy3y3, @samuela, @kuehlein, @bhongy, @chyzwar, @trivikr, @yoursunny, @qwelias, @ExE-Boss, @peterblazejewicz, @addaleax, @victorperin, @nodejs, @LinusU, @wafuwafu13, @mcollina, @Semigradsky: you can do this too.) |
|
Ready to merge |
Please fill in this template.
pnpm test <package to test>.Select one of these and delete the others:
If changing an existing definition:
package.json.I was passing
ArrayBuffer | stringtoBuffer.from, but that started to error after #72056. This PR adds a signature for that case.