You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
the union between a tuple of n>1 elements and an array of such tuples does properly parse the array case correctly #1317
the union between [x,x][] and [x,x] does not properly resolve [x,x][] correctly
[ [ 1, 2 ] ]
must be a number or an object (was undefined)
value at ["1"] must be a number or an object (was undefined)
ReadonlyPath(1) [ '1', cache: { stringifyAncestors: [ '', '["1"]' ] } ]
i actually noticed this with type(["number", "number", "number", "number"])
but it also happens with type(["number","string"]) and probably other cases
🔎 Search Terms
tuple union
array union
tuple array
tuple and tuple array union
🧩 Context
ArkType version: 2.0.4
TypeScript version (5.1+): 5.7.3
Other context you think may be relevant (JS flavor, OS, etc.):
🧑💻 Repro
import{ArkErrors,type}from"arktype";consttupleType=type(["number","number"])consttupleArrayType=tupleType.array()constunionType=tupleType.or(tupleArrayType)// goodtupleType.assert([1,2])// goodtupleArrayType.assert([[1,2]])// no good!constresp=unionType([[1,2]])if(respinstanceofArkErrors){consterr=resp[0]console.log(err.problem)console.log(err.message)console.log(err.path)}
Activity
elee1766 commentedon Feb 18, 2025
for my use case, i was able to get around it by just doing
avoiding the tuples entirely, but others might not be as lucky
ssalbdivad commentedon Feb 23, 2025
Just tested this and it was fixed as a side effect of the other discrimination improvements that were made in 2.1.0 🎉