Type typed-array copyWithin as returning the typed array, and map as keeping the element type
Why
copyWithin and copyAllWithin return the typed array they mutated, but were typed as returning an array, so Array.push on the result compiled and threw. A typed array's map converts each result to its own element type, but TypedArray.map let f change the type, so a TypedArray.t<string> held numbers.
modifiedTyping TypedArray and per-module externals
rescript
Before
After
external copyAllWithin: (t<'a>, ~target: int) => array<'a>external map: (t<'a>, 'a => 'b) => t<'b>external mapWithIndex: (t<'a>, ('a, int) => 'b) => t<'b>external copyAllWithin: (t<'a>, ~target: int) => t<'a>external map: (t<'a>, 'a => 'a) => t<'a>external mapWithIndex: (t<'a>, ('a, int) => 'a) => t<'a>// Int32Array and the other modules// Int32Array and the other modulesexternal copyAllWithin: (t, ~target: int) => array<int>external copyAllWithin: (t, ~target: int) => t
copyWithin changes like copyAllWithin, and loses a duplicated @send.