Semantic Diff

#9112 Type typed-array copyWithin as returning the typed array, and map as keeping the element type

1 commit

85f31fbb15ef96bd168d6e99055ad4808810d6e0..pr-9112

489f49e09 · cknitt + Claude · Oct 28, 2026, 15:26 UTC

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.