#Recursive transform issue

5 messages · Page 1 of 1 (latest)

rugged abyss
#

would be very cool if ts had a builtin utility type for recursive transforms

ashen torrentBOT
#
m.a.t.t.t#0

Preview:```ts
// project schema

type A = { a: string }
type B = { b: boolean }
type C = { c: number }
type D = { d: string[] }
type E = { e: boolean[] }

type Union = A | B | C | D | E

type Foo = {
not: string
union: Union
narrow: A
}

type Bar = {
nested: {
inner: B
...```

rugged abyss
#

ughhh my brain 🤯 this is a tough one. i need to do recursion but enable distributivity in some situations and disbale in others...

ashen torrentBOT
#
m.a.t.t.t#0

Preview:```ts
// project schema

type A = { a: string }
type B = { b: boolean }
type C = { c: number }
type D = { d: string[] }
type E = { e: boolean[] }
type F = { f: number[] }

type Union = A | B | C | D | E | F

type Foo = {
not: string
union: Union
narrow1: A
...```

rugged abyss
#

ok managed to solve it by splitting into 2 generics - 1 has distributivity enabled and the other doesn't, and i recurse between them

the only thing is the output has an undefined and im not sure where it's coming from