You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No differentiation between ArrayBuffer and Uint8Array聽#55032
TypeScript checks the program above, and reports no errors.
馃檪 Expected behavior
An error should be thrown, because in many APIs, passing a Uint8Array rather than an ArrayBuffer will throw or result in runtime errors.
Cause and proposed fix
The cause for this issue is TypeScript's structural typing. Within the type structure, ArrayBuffer is a subset of structure of Uint8Array. Because of this, TypeScript considers Uint8Array a valid ArrayBuffer type.
To fix this, we should consider adding a brand to the Uint8Array and ArrayBuffer interfaces, such as the following:
Activity
MartinJohns commentedon Jul 15, 2023
Duplicate of #42534, #31311, and ultimately #202.
See also this comment: #31311 (comment)
lucacasonato commentedon Jul 15, 2023
Oh I missed that comment. How unfortunate. I wonder if the breakage actually uncovers real user error...
typescript-bot commentedon Jul 20, 2023
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.