sdk icon indicating copy to clipboard operation
sdk copied to clipboard

JS Interop suggestion: Make JSTypedArray generic

Open nex3 opened this issue 6 months ago • 1 comments

The JSTypedArray class represents an array that can contain several types of data (from Dart's perspective): integers, floating-point numbers, and 64-bit BigInts. Its subclasses all define an in-depth API for accessing these values, but in order to define interop typings for these APIs and make them accessible from Dart, they'd currently each have to be redefined individually.

If JSTypedArray were made generic, and its subclasses made to inherit from specifically JSTypedArray<JSNumber> or JSTypedArray<BigInt>, these typings could be shared across all subclasses. If JSTypedArray<JSNumber> were further divided into JSTypedIntArray and JSTypedDoubleArray, methods like TypedArray.at() and the indexing operator could be used to directly return the appropriate Dart numeric types.

nex3 avatar Jun 04 '25 22:06 nex3

cc @srujzs

devoncarew avatar Jun 05 '25 01:06 devoncarew