Skip to content

Commit e19347a

Browse files
committed
ok
1 parent 4985a36 commit e19347a

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

ark/repo/scratch.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import { scope, type } from "arktype"
1+
import { join } from "@ark/util"
2+
import { type } from "arktype"
23

3-
const $ = scope({
4-
Foo: {
5-
"oneOf?": "Bar[]" // NB: don't get the error if this is not an array
6-
},
7-
Bar: "Foo"
8-
}).export()
4+
const options = ["red", "blue"] as const
95

10-
const baz = $.Bar.pipe((_: object): type.Any | undefined => {
11-
console.log("this never gets logged since pipe isn't entered")
12-
return type("string")
13-
})
6+
const color = type.enumerated(...options)
147

15-
const r = baz({ oneOf: [{}] }) // throws "TypeError: this.Foo1Apply is not a function"
16-
console.log(r?.toString())
8+
const darkColorLiteral = type.enumerated(
9+
...options.map(base => `${base}Dark` as const)
10+
)
11+
12+
const darkColorRegex = type(`/^(${join(options, "|")})Dark$/`)

0 commit comments

Comments
 (0)