#26
fix(expr): Object.keys/values/entries accept strings and arrays
Object.keys, Object.values and Object.entries throw Expected an object for strings and arrays, while plain JS returns their index keys. Models write Object.keys(result) on tool output fairly often, and when that output is text or a list the script fails on a message that doesn't say what it got.
Summary
Object.keys(v)
- v is not a plain object -> "Expected an object"
+ v is null or undefined -> "Object.keys expects an object, got null"
+ anything else -> same as JS (strings/arrays give index keys)Only keys, values and entries change. fromEntries and groupBy keep their checks.
Evidence
- Before:
Object.keys("ab")->ExprError: Expected an object(new test fails onmain) - After:
["0", "1"];Object.values([1, 2])->[1, 2];Object.keys(null)->Object.keys expects an object, got null
vitest run: 283 passed. tsc --noEmit and biome check clean.
Merge Danger
Door: two-way
Blast Radius: small. Scripts that relied on the throw for strings/arrays now get keys instead. Heads-up: #6 adds an Object.assign that calls asRecord, which this PR renames to asKeyed, so whichever lands second needs a one-line touch. Happy to rebase.
Thanks for callscript!
Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel.
A member of the Team first needs to authorize it.