sdk
sdk copied to clipboard
JS Interop suggestion: Make JSTypedArray generic
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.
cc @srujzs