We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4985a36 commit e19347aCopy full SHA for e19347a
1 file changed
ark/repo/scratch.ts
@@ -1,16 +1,12 @@
1
-import { scope, type } from "arktype"
+import { join } from "@ark/util"
2
+import { type } from "arktype"
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()
+const options = ["red", "blue"] as const
9
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
-})
+const color = type.enumerated(...options)
14
15
-const r = baz({ oneOf: [{}] }) // throws "TypeError: this.Foo1Apply is not a function"
16
-console.log(r?.toString())
+const darkColorLiteral = type.enumerated(
+ ...options.map(base => `${base}Dark` as const)
+)
+
+const darkColorRegex = type(`/^(${join(options, "|")})Dark$/`)
0 commit comments