wynn/ts/scratch/test.ts
a 53f46934e8
Some checks failed
commit-tag / commit-tag-image (map[context:./migrations file:./migrations/Dockerfile name:migrations]) (push) Successful in 21s
commit-tag / commit-tag-image (map[context:./ts file:./ts/Dockerfile name:ts]) (push) Has been cancelled
noot
2025-06-14 18:04:46 -05:00

21 lines
461 B
TypeScript

import { ArkErrors, type } from 'arktype'
const tupleType = type(['number', 'string'])
const tupleArrayType = tupleType.array()
const unionType = tupleType.or(tupleArrayType)
// good
tupleType.assert([1, '2'])
// good
tupleArrayType.assert([[1, '2']])
// no good!
const resp = unionType([[1, '2']])
if (resp instanceof ArkErrors) {
const err = resp[0]
console.log(err.data)
console.log(err.problem)
console.log(err.message)
console.log(err.path)
}