rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
25 lines (15 loc) • 1.1 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [rc-js-util](./rc-js-util.md) > [TTypedArrayCast](./rc-js-util.ttypedarraycast.md)
## TTypedArrayCast type
Typed array tuples of the same dimension but different storage type (e.g. float32 vs int32) are not structurally compatible by design. Where an implicit conversion is desired you can cast between typed array tuples of the same dimension using this utility type as described in the example.
**Signature:**
```typescript
export type TTypedArrayCast<U extends ATypedArrayTuple<number, TTypedArray>> = TPickExcept<U, "TTypeGuardTypedArray" | keyof ATypedArrayTuple<number, TTypedArray>>;
```
**References:** [ATypedArrayTuple](./rc-js-util.atypedarraytuple.md)<!-- -->, [TTypedArray](./rc-js-util.ttypedarray.md)<!-- -->, [TPickExcept](./rc-js-util.tpickexcept.md)
## Example
```typescript
const vec4 = Vec4.f32.factory.createOneEmpty();
type TVec4I32 = AVec4<TTypedArray.I32>;
const ivec4: TVec4I32 = vec4 as TTypedArrayCast<TVec4I32> as TVec4I32;
```