Options
All
  • Public
  • Public/Protected
  • All
Menu

Type aliases

Type aliases

AutoPath

AutoPath<O, P, D>: _AutoPath<O, P, D>

Auto-complete, validate, and query the string path of an object O

Type parameters

  • O: any

    to work on

  • P: string

    path of O

  • D: string

    (?='.') delimiter for path

    declare function get<O extends object, P extends string>(
        object: O, path: AutoPath<O, P>
    ): Path<O, Split<P, '.'>>
    
    declare const user: User
    
    type User = {
        name: string
        friends: User[]
    }
    
    // works
    const friendName = get(user, 'friends.40.name')
    const friendFriendName = get(user, 'friends.40.friends.12.name')
    
    // errors
    const friendNames = get(user, 'friends.40.names')
    const friendFriendNames = get(user, 'friends.40.friends.12.names')
    
  • Inherited
  • Protected
  • Private
  • Static
  • Module
  • Object
  • Property
  • Function
  • Variable
  • Index
  • Type
  • Class
  • Interface
  • Enum
  • Constructor
  • Getter/Setter
Made with ❤️ by pirix-gh. Documentation generated by TypeDoc.