Skip to content

Incorrect constructor overload: takes only first overload, but not others #60745

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

https://www.typescriptlang.org/play/?target=9&ts=5.7.2#code/FAFwngDgpgBAkgOwCZQB4FEA2UC2UEgDOAwgPYKEgBOArgMYilUwC8MAqgJYEDMATAEEqVAIZgyFavUbMAPh24gAjADYho8eUq0GTGPK4EAHOrETt0pgG5gwAGY0EDTuRggolABR1SOCOXwQABVIKAAuGAQaHAAjKCoAGhg6AAtHAGsAEREQEQAhbgjTMDyaOzt4gEoYAG9gGAaYbBAYADdOKAB3EOgIxBQMbDwCEi0pXSobesbCTs4QVJhvX38EQJ6oarrGneSRQlgAdSgYgHEAGT4AJXwUKm4Acwl3VBAAOnYAOQBlOFPP9CZAD6cE+QTC012u3aXQ2rAUvEEwjEUyhUJiVCgInSqLRdH2RxOF2ut3ij2eaHeX1+-0BQO+AAkAPJXcGQtENGHdULwwzKNTIsC4jkNDFYnG2Dn4g4wY5nS43ZBkhBPcgvKk-P4A4F5ACaQXQEJFjS5cLYfJMguFIrF2OtOxQdhENEwICNxrcKSopE6kS6MHQwiYngABgAiHx+AIEDZhmCcQiRUgtalaumgoJJVO04GMllBGB6bPaoF6g1LAAkNUjq3WoQAvpUQ5UbDt65LGj5JHtMHQXTkoEhSuV4kzygcWmwACytztjHt9zADodlCpUc74B4gFLwozWzEgGhUBB+32m0LeNIILI5fLcJL43v99wrkdUMd2CcPkRPpcv4drhuKrbi2wDtkAA

💻 Code

typeIndexElementsConstructor=Uint32ArrayConstructor|Uint16ArrayConstructor|Uint8ArrayConstructor;functiontest(componentType: number,chunkDataBin: ArrayBuffer){letviewType: IndexElementsConstructor;switch(componentType){caseWebGL2RenderingContext.UNSIGNED_INT:
viewType=Uint32Array;break;caseWebGL2RenderingContext.UNSIGNED_SHORT:
viewType=Uint16Array;break;caseWebGL2RenderingContext.UNSIGNED_BYTE:
viewType=Uint8Array;break;default:
thrownewError(`"componentType" is not UNSIGNED_INT, UNSIGNED_SHORT or UNSIGNED_BYTE (${componentType})`);}constcalculatedBufferOffset=4;constcalculatedBufferLength=8;returnnewviewType(chunkDataBin,calculatedBufferOffset,calculatedBufferLength);}

🙁 Actual behavior

Image

🙂 Expected behavior

Image

Additional information about the issue

If change code to simpler variant:

typeIndexElementsConstructor=Uint32ArrayConstructor|Uint16ArrayConstructor|Uint8ArrayConstructor;functiontest(componentType: number,chunkDataBin: ArrayBuffer){constviewType: IndexElementsConstructor=Uint32Array;constcalculatedBufferOffset=4;constcalculatedBufferLength=8;returnnewviewType(chunkDataBin,calculatedBufferOffset,calculatedBufferLength);}

newest TS version recognizes this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions