-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Closed
Copy link
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
π Search Terms
constructor, typescript, Uint32Array, Uint16Array, Uint8Array, Uint32ArrayConstructor, Uint16ArrayConstructor, Uint8ArrayConstructor
π Version & Regression Information
- This changed between versions 5.6.3 and 5.7.2
β― Playground Link
π» Code
type IndexElementsConstructor = Uint32ArrayConstructor | Uint16ArrayConstructor | Uint8ArrayConstructor;
function test(componentType: number, chunkDataBin: ArrayBuffer) {
let viewType: IndexElementsConstructor;
switch (componentType) {
case WebGL2RenderingContext.UNSIGNED_INT:
viewType = Uint32Array;
break;
case WebGL2RenderingContext.UNSIGNED_SHORT:
viewType = Uint16Array;
break;
case WebGL2RenderingContext.UNSIGNED_BYTE:
viewType = Uint8Array;
break;
default:
throw new Error(`"componentType" is not UNSIGNED_INT, UNSIGNED_SHORT or UNSIGNED_BYTE (${componentType})`);
}
const calculatedBufferOffset = 4;
const calculatedBufferLength = 8;
return new viewType(chunkDataBin, calculatedBufferOffset, calculatedBufferLength);
}
π Actual behavior
π Expected behavior
Additional information about the issue
If change code to simpler variant:
type IndexElementsConstructor = Uint32ArrayConstructor | Uint16ArrayConstructor | Uint8ArrayConstructor;
function test(componentType: number, chunkDataBin: ArrayBuffer) {
const viewType: IndexElementsConstructor = Uint32Array;
const calculatedBufferOffset = 4;
const calculatedBufferLength = 8;
return new viewType(chunkDataBin, calculatedBufferOffset, calculatedBufferLength);
}
newest TS version recognizes this.
simonvarey and kzhsw
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed