Metakit / @doeixd/metakit

PathAccessor

type · packages/metakit/src/path.ts:276

type PathAccessor<
  Env,
  A,
  Writable extends boolean = false,
> = (Writable extends true ? StatePath<Env, Read<A>> : Path<Env, Read<A>>) &
  AccessorFields<Env, Read<A>, Writable>

Recursive typed accessor for an environment value A: every plain object property (including TypeScript interfaces) becomes a nested PathAccessor<Env, A[K]>, and every level is itself a Path<Env, A>. An Option reads as its value or null, and a field under a value that may be null may be null too, as evaluation reads it.

A field named as a member of Path itself (node, segments, ast) is not reached by its name, which reads the member: compose it, Path.compose(parent, Path.field('segments')).