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
Playground Link: https://arktype.io/playground?code=import%2520%257B%2520type%2520%257D%2520from%2520%2522arktype%2522%250A%250Aconst%2520Thing%2520%253D%2520type%28%2522number%255B%255D%2522%29%250A%250Alet%2520x%253B%250Aconst%2520f%2520%253D%2520%28%29%2520%253D%253E%2520%257B%250A%2520%2520%2520%2520const%2520window_%2520%253D%2520window.open%28%29%21%253B%250A%2520%2520%2520%2520window_.eval%28%2522var%2520x%2520%253D%2520%255B1%255D%2522%29%253B%250A%2520%2520%2520%2520x%2520%253D%2520window_.x%253B%250A%257D%250A%252F%252F%2520f%28%29%2520%252F%252F%2520%253C-%2520uncomment%2520this%2520line%252C%2520note%2520that%2520it%2520will%2520open%2520a%2520new%2520tab%250A%250Aconst%2520out%2520%253D%2520Thing%28x%29%250A
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.
Report a bug
🔎 Search Terms
array Array.isArray window realm
🧩 Context
🧑💻 Repro
Playground Link: https://arktype.io/playground?code=import%2520%257B%2520type%2520%257D%2520from%2520%2522arktype%2522%250A%250Aconst%2520Thing%2520%253D%2520type%28%2522number%255B%255D%2522%29%250A%250Alet%2520x%253B%250Aconst%2520f%2520%253D%2520%28%29%2520%253D%253E%2520%257B%250A%2520%2520%2520%2520const%2520window_%2520%253D%2520window.open%28%29%21%253B%250A%2520%2520%2520%2520window_.eval%28%2522var%2520x%2520%253D%2520%255B1%255D%2522%29%253B%250A%2520%2520%2520%2520x%2520%253D%2520window_.x%253B%250A%257D%250A%252F%252F%2520f%28%29%2520%252F%252F%2520%253C-%2520uncomment%2520this%2520line%252C%2520note%2520that%2520it%2520will%2520open%2520a%2520new%2520tab%250A%250Aconst%2520out%2520%253D%2520Thing%28x%29%250A
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.someDataand 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 Arrayto test whether something is an array, which is not quite correct. The more correct way to test whether something is an array is to useArray.isArray(this is basically the reasonArray.isArrayexists 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
structuredCloneto all my values before feeding them to ArkType, but it would be better for ArkType to handle arrays properly.