#Omit a value from type x = 'a' | 'b' | 'c'

12 messages · Page 1 of 1 (latest)

tawdry valve
#
white hollyBOT
#

@tawdry valve Here's a shortened URL of your playground link! You can remove the full link from your message.

Pluto#2649

Preview:```ts
const x = [
{
a: "value-1",
},
{
a: "value-2",
},
{
a: "value-3",
},
] as const

type X = typeof x[number]["a"]

// X -> 'value-1' | 'value-2' | 'value-3'
// But i want to omit this for a case where i only want X -> 'value-1' | 'value-2'```

olive pollen
#

!hb utility types

white hollyBOT
olive pollen
#

on mobile so can't really check the example, sorry

#

you can use Extract and Exclude to modify unions

tawdry valve
#

Thanks. That helps

olive pollen
#

on pc now; have you solved your query? @tawdry valve

tawdry valve
#

Yeah i got it

#

Didn't know about exlude . Been working with objecf types mostly

#

Thanks again though

olive pollen
#

!resolved