ReviewOS

home-lang/home

fix(ts): model iterator helper methods on iterator receivers

#969
Open glennmichael123 opened this 12 hours ago ·
12 hours ago

Related: #960, #66.

TypeScript 5.7.3 declares iterator helpers on IteratorObject<t>, not Array<t>. A control using [1,2,3].values().filter(...).map(...).toArray() has an iterator after filter/map and an array only after toArray. Home currently accepts the chain because lib.arrayProto incorrectly has a toArray method. Removing that member exposes the real gap: checker treats the iterator object (which stores its yielded T in a numeric index slot) as an array, so filter returns T[] and map follows Array semantics. The full checker test checker: ES2025 Float16Array global and iterator helper toArray are recognized failed after removing the erroneous Array method (4733 pass / 1 fail). That removal is not yet committed.

Fix the underlying type model: recognize IteratorObject receivers before array-prototype fallback, give filter/map/take/drop/toArray and other helpers the TypeScript iterator return/callback types, preserve generic inference, and ensure Array<t> itself has no toArray. Compare TypeScript 5.7.3 controls for iterator chains and direct array.toArray, then run checker, Program, LSP and exact CLI tests under the memory guard. No name-based diagnostic suppression or Array-only proxy method.

12 hours ago

Pushed 256d787 and 347f3ec. Array<t> no longer exposes iterator-only toArray; iterator receivers are recognized before numeric-index array fallback. Iterator filter preserves yielded T, generic map yields an iterator of U, and toArray returns U[]. Added a checker test for the typed chain and the missing direct Array method, plus an exact TypeScript 5.7.3 CLI fixture. Direct checker: 4,735/4,735 passed; the new CLI fixture matches tsc's TS2339 exactly. The expanded 140-project audit and Program/LSP runs await memory headroom. This issue stays open for the remaining IteratorObject helper methods and overload/type precision. Related #960.

12 hours ago

Final gates for the current batch: direct checker 4,735/4,735; TypeScript 5.7.3 exact CLI audit 140/140; guarded Program step passed; guarded exact LSP step passed; targeted pickier passed. Latest pushed main commit: 3f68c9b. The checkout has only pre-existing unrelated untracked files. Keeping this issue open for the remaining behavior noted above.

Sign in to comment on this issue.