I’ve recently been using TypedArrays more for manual memory management / custom data storage, and find myself somewhat struggling with the lack of good typing support in TypeScript w.r.t. TypedArrays. eg. Even if I can define a number value type union such as <pre lang=“typescript”><code>type Kind = 0 | 1 | 2 | 3 | 4 | 5; </code></pre> I have no way of defining a <code>Uint8Array</code> that contains only this <code>Kind</code> type. After working around this with <code>arr[i] as Kind</code> casting and getting bit a few times by refactorings breaking the code but the <code>as</code> cast types not catching this, I opened up a feature suggestion for TypeScript (the pits, I know…) to support this. One response I got was to say that this is a niche use-case, and that made me wonder: What are JavaScript/TypeScript developers actually using TypedArrays for, if <code>number</code> is a sufficient value type in all but niche use-cases? If you have open-source code examples to point to, that’s awesome, but I’m interested in user stories / written word as well.

