arktypea
arktype16mo ago
errata

template literal/backtick string types e.g. type T = `type-${string}`

I can't see how to do in Ark:

type UserId = `user-${string}`

I specifically want compile-time checking.
Tried to drop it in "1:1" style, but this doesn't work as-is:
const UserId = type('`user-${string}`') // doesn't work

nor did it work trying to use 'type' as a tagged template:
const UserId = type`user-${type('string')}`


I did look in the docs but I don't believe it's there yet, and if it's in the tests I didn't spot it

Do I have to set it up as a custom string constraint so it'd be like const UserId = type('string-userId')?

IIUC this doesn't get the compile-time checking:

// Subtypes like 'email' are inferred like 'string' but provide additional validation at runtime.
email: "string.email",
Was this page helpful?