types: declare bytes() and TextEncoderStream output as Uint8Array<ArrayBuffer> #9016
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.36) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 193 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.315
Real PR Conversation Timeline
1 comments
"Review active on #9016"
general
weight: 0.35
petebacondarwin
Follow-up to #8996, as suggested in its review.
Blob.bytes(),Body.bytes()(soRequestandResponse),R2ObjectBody.bytes()and the chunksTextEncoderStreamemits are all views over fresh, non-sharedArrayBuffers, but they were declared with the bareUint8Array. Since TypeScript 5.7 that meansUint8Array<ArrayBufferLike>, which includesSharedArrayBuffer, so passing the result where aUint8Array<ArrayBuffer>(or aBufferSourcethat rejects shared memory) is expected fails with TS2322/TS2345. TypeScript's ownlib.dom.d.tsdeclares these asUint8Array<ArrayBuffer>.Changes
src/workerd/api/blob.h,http.h,r2-bucket.h:bytes(): Promise<Uint8Array<ArrayBuffer>>in theJSG_TS_OVERRIDEs.src/workerd/api/streams/encoding.h:TextEncoderStream extends TransformStream<string, Uint8Array<ArrayBuffer>>.types/generated-snapshot/: the matching changes in the four snapshot files.types/test/types/bytes.ts: a type test for the fourbytes()methods,.bufferbeing anArrayBuffer, andTextEncoderStream'sreadable/writable.As noted on #8996, this keeps TypeScript 5.7 as the minimum for these declarations.
Testing
With TypeScript 6.0.3 (the repo's version), the new type test passes against both updated snapshots and fails with TS2345 on every assertion against the current ones. As in #8996, I could not run
just generate-typeslocally (Windows), so the snapshot lines were updated by hand and checked against Prettier's output; CI'scheck-snapshotwill confirm them.