#FixedUint8Array
4 messages · Page 1 of 1 (latest)
Preview:```ts
interface FixedUint8Array<L extends number>
extends Uint8Array {
length: L
}
const a: FixedUint8Array<16> = new Uint8Array(16)```
You can choose specific lines to embed by selecting them before copying the link.
this type does what you want:
type FixedUint8Array<L extends number> = Uint8Array & { length: L }
the issue is that you cant assign a regular Uint8Array to it since the length type returned by that is just number instead of a literal number, so youll need to cast the result instead:
Preview:ts ... const a: FixedUint8Array<16> = new Uint8Array(16); // unfortunately this doesnt work ...