fix(landing): avoid unpolyfilled ES2023 array methods (toSorted/toReversed) in client code#5340
Conversation
toSorted/toReversed require Safari 16+/iOS 16+ and Next.js/SWC does not polyfill prototype methods (vercel/next.js#58421 closed unmerged), so #5326 broke sorting on the models page and landing preview for Safari 15/iOS 15 with a runtime TypeError. Revert the 6 call sites to [...arr].sort()/[...arr].reverse() (immutable, universally supported, matches the existing codebase idiom) and drop the ES2023 tsconfig lib override that only existed to type-check them.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview All six call sites now use
Reviewed by Cursor Bugbot for commit 6677cb6. Configure here. |
Greptile SummaryThis PR fixes a runtime
Confidence Score: 5/5Safe to merge — all changes are minimal, targeted replacements of ES2023 array methods with universally-supported equivalents, plus a tsconfig cleanup that restores a type-level guardrail. Every substitution is semantically equivalent: [...arr].sort() and [...arr].reverse() produce the same immutable result as toSorted/toReversed and match the idiom used in eight other places in the codebase. The integrations/[slug]/page.tsx case calls .sort() directly on a fresh Array.from() result — no external array is mutated. Removing the ES2023 lib override from tsconfig.json is a one-line change that only restricts which type definitions are available, with no runtime effect. No new logic is introduced. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Client renders landing page] --> B{Browser supports ES2023 Array methods?}
B -- Safari 16+ or Chrome or Firefox --> C[toSorted / toReversed works]
B -- Safari 15 or iOS 15 or older --> D[TypeError - method not found]
subgraph Fix Applied
E["spread array first: ...arr"] --> F["call .sort() or .reverse() on copy"]
F --> H[Original unchanged - all browsers supported]
end
D -- PR fix --> E
C -- PR fix --> E
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[Client renders landing page] --> B{Browser supports ES2023 Array methods?}
B -- Safari 16+ or Chrome or Firefox --> C[toSorted / toReversed works]
B -- Safari 15 or iOS 15 or older --> D[TypeError - method not found]
subgraph Fix Applied
E["spread array first: ...arr"] --> F["call .sort() or .reverse() on copy"]
F --> H[Original unchanged - all browsers supported]
end
D -- PR fix --> E
C -- PR fix --> E
Reviews (1): Last reviewed commit: "fix(landing): avoid unpolyfilled ES2023 ..." | Re-trigger Greptile |
Summary
Array.prototype.toSorted/toReversed(ES2023) require Safari 16+ / iOS 16+ and Next.js/SWC does not polyfill prototype methods (vercel/next.js#58421 was closed unmerged per maintainer policy). So the react-doctor pass in improvement(landing): react-doctor health pass across the landing surface #5326 introduced a runtimeTypeError: … toSorted is not a functionon Safari 15 / iOS 15 — breaking sorting on the models page and the landing preview (logs/resource) plus the lifecycle monitor icon.[...arr].sort()/[...arr].reverse()— immutable (copies first), universally supported, and matching the existing codebase idiom (8 other[...x].sort()sites)."lib": ["ES2023", …]override inapps/sim/tsconfig.jsonthat only existed to type-checktoSorted; back on the inherited ES2022 lib, these methods no longer type-check, restoring the guardrail against re-introduction.toSorted/toReversed/toSplicedusages — the issue exists nowhere else.Type of Change
Testing
tsc --noEmitclean on the ES2022 baseline (0 errors),biome checkclean,bun run lintclean. Verified no remaining ES2023 array-method usages repo-wide. Browser support + Next.js no-polyfill behavior validated against caniuse and the Next.js issue/PR threads.Checklist