Giacomo Tagliabue
Giacomo Tagliabue

Reputation: 1759

typescript anonymous nested types

given the following type:

type Foo = {
  a: {
    b: number
    c: string
  }
  d: number
}

is there a way to retrieve the anonymous nested types? I was thinking something like TypeOf<Foo, 'a'> should return the type made of b and c and TypeOf<Foo, 'd'> should be an alias to number. I made up the syntax, but I wanted to know if a similar concept exists

Upvotes: 0

Views: 109

Answers (1)

Giacomo Tagliabue
Giacomo Tagliabue

Reputation: 1759

turns out you can do this by doing Foo['a']. Great!

Upvotes: 1

Related Questions