Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "api/path"

Index

Type aliases

DeepPath

DeepPath<T, A, B, C, D, E, F, G, H>: A extends Keys<T> ? B extends Keys1<T, A> ? C extends Keys2<T, A, B> ? D extends Keys3<T, A, B, C> ? E extends Keys4<T, A, B, C, D> ? F extends Keys5<T, A, B, C, D, E> ? G extends Keys6<T, A, B, C, D, E, F> ? H extends Keys7<T, A, B, C, D, E, F, G> ? keyof [A, B, C, D, E, F, G, H, string | number] : never : never : never : never : never : never : never : never

Semi-typechecked lookup path (depth > 8). Only the first 8 levels are checked.

Type parameters

  • T

  • A

  • B

  • C

  • D

  • E

  • F

  • G

  • H

IsOpt

IsOpt<T>: T extends undefined ? true : never

Returns true if T includes undefined.

Type parameters

  • T

IsOptPath

IsOptPath<T, P>: P extends [] ? never : IsOptR<T, Head<P>, Tail<P>>

Returns true if given path contains any intermediate properties declared as optional in type T.

Reference: https://stackoverflow.com/q/60869412/294515

Type parameters

  • T

  • P: unknown[]

IsOptR

IsOptR<T, K, P>: K extends Keys<T> ? [true] extends [IsOpt<T[K]>] ? true : { 0: IsOptR<Required<T>[K], Head<P>, Tail<P>>; 1: never }[IsEmpty<P>] : never

Internal recursive helper type for IsOptPath.

Type parameters

  • T

  • K

  • P: unknown[]

OptPathVal

OptPathVal<T, P>: OptVal<IsOptPath<T, P>, ValN<T, P>>

Similar to PathVal, but also takes into account if given path contains any intermediate properties declared as optional in type T. If that's the case, returns union of undefined and inferred value for path, else just the latter.

Context & reference: https://stackoverflow.com/q/60869412/294515

Type parameters

  • T

  • P: unknown[]

OptVal

OptVal<PRED, RES>: [PRED] extends [never] ? RES : RES | undefined

Returns RES if PRED is never, else RES | undefined

Type parameters

  • PRED

  • RES

Path

Path: keyof NumOrString[] | NumOrString

Unchecked lookup path for nested data structures.

Path0

Path0: keyof []

Empty lookup path.

Path1

Path1<T, A>: A extends Keys<T> ? keyof [A] : never

Type checked lookup path (depth 1)

Type parameters

  • T

  • A

Path2

Path2<T, A, B>: A extends Keys<T> ? B extends Keys1<T, A> ? keyof [A, B] : never : never

Type checked lookup path (depth 2)

Type parameters

  • T

  • A

  • B

Path3

Path3<T, A, B, C>: A extends Keys<T> ? B extends Keys1<T, A> ? C extends Keys2<T, A, B> ? keyof [A, B, C] : never : never : never

Type checked lookup path (depth 3)

Type parameters

  • T

  • A

  • B

  • C

Path4

Path4<T, A, B, C, D>: A extends Keys<T> ? B extends Keys1<T, A> ? C extends Keys2<T, A, B> ? D extends Keys3<T, A, B, C> ? keyof [A, B, C, D] : never : never : never : never

Type checked lookup path (depth 4)

Type parameters

  • T

  • A

  • B

  • C

  • D

Path5

Path5<T, A, B, C, D, E>: A extends Keys<T> ? B extends Keys1<T, A> ? C extends Keys2<T, A, B> ? D extends Keys3<T, A, B, C> ? E extends Keys4<T, A, B, C, D> ? keyof [A, B, C, D, E] : never : never : never : never : never

Type checked lookup path (depth 5)

Type parameters

  • T

  • A

  • B

  • C

  • D

  • E

Path6

Path6<T, A, B, C, D, E, F>: A extends Keys<T> ? B extends Keys1<T, A> ? C extends Keys2<T, A, B> ? D extends Keys3<T, A, B, C> ? E extends Keys4<T, A, B, C, D> ? F extends Keys5<T, A, B, C, D, E> ? keyof [A, B, C, D, E, F] : never : never : never : never : never : never

Type checked lookup path (depth 6)

Type parameters

  • T

  • A

  • B

  • C

  • D

  • E

  • F

Path7

Path7<T, A, B, C, D, E, F, G>: A extends Keys<T> ? B extends Keys1<T, A> ? C extends Keys2<T, A, B> ? D extends Keys3<T, A, B, C> ? E extends Keys4<T, A, B, C, D> ? F extends Keys5<T, A, B, C, D, E> ? G extends Keys6<T, A, B, C, D, E, F> ? keyof [A, B, C, D, E, F, G] : never : never : never : never : never : never : never

Type checked lookup path (depth 7)

Type parameters

  • T

  • A

  • B

  • C

  • D

  • E

  • F

  • G

Path8

Path8<T, A, B, C, D, E, F, G, H>: A extends Keys<T> ? B extends Keys1<T, A> ? C extends Keys2<T, A, B> ? D extends Keys3<T, A, B, C> ? E extends Keys4<T, A, B, C, D> ? F extends Keys5<T, A, B, C, D, E> ? G extends Keys6<T, A, B, C, D, E, F> ? H extends Keys7<T, A, B, C, D, E, F, G> ? keyof [A, B, C, D, E, F, G, H] : never : never : never : never : never : never : never : never

Type checked lookup path (depth 8)

Type parameters

  • T

  • A

  • B

  • C

  • D

  • E

  • F

  • G

  • H

PathVal

PathVal<T, P>: ValN<T, P>

Returns nested value type for given path into T or never if path is incompatible with T.

Type parameters

  • T

  • P: unknown[]

Generated using TypeDoc