I'm learning about generics, and hitting this issue with the compiler:
type FloatArray = Float32Array | Float64Array;
type IntegerArray =
| Int8Array
| Uint8Array
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Uint8ClampedArray;
type TypedArray = FloatArray | IntegerArray;
export function identityArray<T extends TypedArray>(array: T): T {
return array.subarray(0);
}
// Type 'TypedArray' is not assignable to type 'T'
What am I doing wrong here?