- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.1k
 
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do thisYou can do this
Milestone
Description
π Search Terms
TypedArray, Uint8Array, ArrayBufferLike, TextEncoder
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about TextEncoder
 
β― Playground Link
π» Code
const data = new TextEncoder().encode("hello")
//    ^? Uint8Array<ArrayBufferLike>
// The `ArrayBufferLike` may include `SharedArrayBuffer`, but `encode()` 
// only supports `ArrayBuffer`, so this breaks code expecting an `ArrayBuffer`.
function processData(d: ArrayBuffer) {
  // do stuff
}
processData(data.buffer) // This should work, but reported as type errorπ Actual behavior
Values returned by TextEncoder.encode are not assignable to ArrayBuffer.
π Expected behavior
Values returned by TextEncoder.encode should be assignable to ArrayBuffer.
Additional information about the issue
nikwen, lionel-rowe and boombang
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do thisYou can do this