Repository navigation
Description
Report a bug
🔎 Search Terms
array Array.isArray window realm
🧩 Context
System:
OS: macOS 26.3
CPU: (8) arm64 Apple M2
Memory: 108.88 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 25.8.0 - /Users/guillaumeb/.nvm/versions/node/v25.8.0/bin/node
npm: 11.11.0 - /Users/guillaumeb/.nvm/versions/node/v25.8.0/bin/npm
bun: 1.3.10 - /Users/guillaumeb/.bun/bin/bun
npmPackages:
@ark/schema: 0.56.0
@ark/util: 0.56.0
arktype: ^2.2.0 => 2.2.0
typescript: ^5.7.3 => 5.9.3
🧑💻 Repro
declare const x: number[];
// x is [1], but defined in a different window, for instance an iframe or a popup window
const Thing = type("number[]");
const out = Thing(x);
// > must be an array (was object)
// (incorrect error, it is an array so it should be parsed properly)ArkType does not appear to properly handle arrays created in a different realm (for instance an iframe or a popup window). The playground code is a bit convoluted, but it happens to me in actual code: I have an app which lives in a popup window and gets data from the main window via opener.someData and then I want to parse it. But arrays aren’t recognized as arrays, so it fails.
Stepping through the code in the DevTools shows that ArkType uses v instanceof Array to test whether something is an array, which is not quite correct. The more correct way to test whether something is an array is to use Array.isArray (this is basically the reason Array.isArray exists at all: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray#description).
I’m trying to replace Zod with ArkType because of performance issues, great experience so far both with respect to performance and DX, but this is one blocker I have so far.
I think I can work around it by applying structuredClone to all my values before feeding them to ArkType, but it would be better for ArkType to handle arrays properly.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone (merged or closed)
Activity
pullfrog commentedon Mar 15, 2026
fix(schema): recognize cross-realm arrays with Array.isArray (arktype…