© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
arktypea
arktype•12h ago
bigboyjo

String literal union

Is there a way to achieve this?

type Columns = 'name' | 'id'
type Negated = Columns | `-${Columns}`
type Columns = 'name' | 'id'
type Negated = Columns | `-${Columns}`


I tried doing:
type('("name" | "id") | ("-" & ("name" | "id"))')
type('("name" | "id") | ("-" & ("name" | "id"))')
but this just results in
'name' | 'id'
'name' | 'id'


And this
type('("-" & ("name" | "id"))')
type('("-" & ("name" | "id"))')
results in
never
never
arktype banner
arktypeJoin
This is a friendly space centered around ArkType, TypeScript's 1:1 validator (https://github.com/arktypeio/arktype)
860Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

using an const array as a source for a string literal union
arktypeaarktype / questions
2y ago
template literal/backtick string types e.g. type T = `type-${string}`
arktypeaarktype / questions
2y ago
Cast empty string in place for literal as default value
arktypeaarktype / questions
6mo ago
Generic loses literal
arktypeaarktype / questions
13mo ago