#mapped typed issue

8 messages · Page 1 of 1 (latest)

fiery sinewBOT
#
piscopancer#0

Preview:```ts
type Ltx = {
inventories: string | string[]
boosts: string
}

type DltxEntries<O extends object> = Partial<
{
[K in keyof O]: (O[K] extends any[]
? {
[_ in K | ${"<" | ">"}${K & string}]: any
}
: {}) & {
[_ in K | !${K & string}]: undefined
} & {
[_ in K]: any
}
}[keyof O]

const test: DltxEntries<Ltx> = {
// no < and > for inventories
}```

elder silo
#

So i have this type and I expected to have < and > for a type that extends an array, it can also be a union with array as one of possible types - have < and > as well

#

so whenever array appears, in a union or as is, < and > should be enabled

#

change inventories: string | string[] to inventories: string[] and you will see the type of test variable that I expected

vernal sail
#

add an infer clause to distribute

O[K] extends infer U ? U extends any[] ? ...

elder silo
#

!resolved