Title: Incorrect type returned by TextEncoder.encode · Issue #60846 · microsoft/TypeScript · GitHub
Open Graph Title: Incorrect type returned by TextEncoder.encode · Issue #60846 · microsoft/TypeScript
X Title: Incorrect type returned by TextEncoder.encode · Issue #60846 · microsoft/TypeScript
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 Playground link ...
Open Graph 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 TextEn...
X 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 Te...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/60846
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect type returned by TextEncoder.encode","articleBody":"### 🔎 Search Terms\n\nTypedArray, Uint8Array, ArrayBufferLike, TextEncoder\n\n### 🕗 Version & Regression Information\n\n- This is the behavior in every version I tried, and I reviewed the FAQ for entries about TextEncoder\n\n\n\n### ⏯ Playground Link\n\n[Playground link](https://www.typescriptlang.org/play/?target=99#code/MYewdgzgLgBAJgQygmBeGYCmB3GAVTADygFExQ5MAnACgEoA6TckSmgIgAtMAbHkdnQCwAKAD0YmFJgA9APwwAqgEswUABwBBKlQQBPADzbdegEIBXAGaXqAGWUBrTAD5RE-NxgADY-ovW7R0wvGABbfRhVYB5zSm8AZU4EKkw4XzMrGyovABoYACNzWC9mCkx6ELdJcB49GAhzAAdGkCooCG90-yzc+pAYKE5lDvyUhAcOspgiRsxgKFUAcxgEME6dP0zqLwZRUUtzcgXwGEaqEGBMCAgAESQEGjgALhgurao6GABvUSl3OH60EyogAvnsRGcLldbvdHvcGIUAh8YO48EMOhBOCBzDw4DBsK0HHlCrAUi02qkVh0oHpZtMdK0gA)\n\n### 💻 Code\n\n```ts\nconst data = new TextEncoder().encode(\"hello\")\n// ^? Uint8Array\u003cArrayBufferLike>\n// The `ArrayBufferLike` may include `SharedArrayBuffer`, but `encode()` \n// only supports `ArrayBuffer`, so this breaks code expecting an `ArrayBuffer`.\n\nfunction processData(d: ArrayBuffer) {\n // do stuff\n}\n\nprocessData(data.buffer) // This should work, but reported as type error\n```\n\n\n### 🙁 Actual behavior\n\nValues returned by TextEncoder.encode are not assignable to `ArrayBuffer`.\n\n### 🙂 Expected behavior\n\nValues returned by TextEncoder.encode should be assignable to `ArrayBuffer`.\n\n### Additional information about the issue\n\nhttps://stackoverflow.com/a/79300250/1494725","author":{"url":"https://github.com/aryzing","@type":"Person","name":"aryzing"},"datePublished":"2024-12-23T09:09:13Z","url":"https://github.com/microsoft/TypeScript/issues/60846"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8e2c98f2-ae1a-fb9c-5997-48b9d01f5eb0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED80:2E3FEE:8ECB48:B63C04:6B00EBE3 |
| html-safe-nonce | 61e5fef783d2b7bf41102c319952a959d18096cfe3cb1f97a533ae49ad615e83 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDgwOjJFM0ZFRTo4RUNCNDg6QjYzQzA0OjZCMDBFQkUzIiwidmlzaXRvcl9pZCI6IjkwMzAyOTU5OTcyMjEyMzU2ODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d0126856f9348c6eb3c9a61529ae6b620a1647f489ba4e11c3298e0e2da7e3a7 |
| hovercard-subject-tag | issue:2755578833 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/60846/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0a45f606e74c64b9780dd91bd75ae1e3249b6fb2b37edc15f360e83b4e6c837a/microsoft/TypeScript/issues/60846 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0a45f606e74c64b9780dd91bd75ae1e3249b6fb2b37edc15f360e83b4e6c837a/microsoft/TypeScript/issues/60846 |
| og:image:alt | 🔎 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 TextEn... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | aryzing |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width