-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do thisYou can do this
Milestone
Description
π Search Terms
Float16Array
π Version & Regression Information
- Tried 5.9.2
- I was unable to test this on prior versions because irrelevant
β― Playground Link
π» Code
export type TypedArrayConstructor =
| Int8ArrayConstructor
| Uint8ArrayConstructor
| Uint8ClampedArrayConstructor
| Int16ArrayConstructor
| Uint16ArrayConstructor
| Int32ArrayConstructor
| Uint32ArrayConstructor
| Float16ArrayConstructor // comment this line out, the error codes away showing that Float16ArrayConstructor is not compatible with other constructors
| Float32ArrayConstructor
| Float64ArrayConstructor;
export type TypedArray =
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float16Array
| Float32Array
| Float64Array;
export class TypedArrayViewGenerator {
arrayBuffer: ArrayBuffer;
byteOffset: number;
constructor(sizeInBytes: number) {
this.arrayBuffer = new ArrayBuffer(sizeInBytes);
this.byteOffset = 0;
}
getView<T extends TypedArray>(Ctor: TypedArrayConstructor, numElements: number): T {
// gets an error here because `Float16Array` is not following the
// the same pattern as the other typed array views
const view = new Ctor(this.arrayBuffer, this.byteOffset, numElements);
this.byteOffset += view.byteLength;
return view as T;
}
}
export function getView<T extends TypedArray>(arrayBuffer: ArrayBuffer, Ctor: TypedArrayConstructor): T {
// this gets an error too for the same reason
const view = new Ctor(arrayBuffer);
return view as T;
}π Actual behavior
Float16Array should behave the same as other typed array views like Float32Array, Uint32Array etc... It's not
π Expected behavior
Float16Array behaves the same as other typed array views like Float32Array, Uint32Array etc...
Additional information about the issue
No response
dasa
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do thisYou can do this