1

Need find a way to represent type as string literal, just as if it were called from regular code. For example:

interface User {
  name: string
  post: {
    title: string
  }
}

const literalName: Literal<User> = 'name'
const literalPostTitle: Literal<User> = 'post.title'

First level easily accessed with

type Literal<T> = `${keyof T}`

But I don't know how to go deeper in nested structures

whalemare
  • 1,107
  • 1
  • 13
  • 30

0 Answers0