Ramonda

RML001 — a path that could not be reached

const profile: { profile: { city: string } | null } = { profile: null };

focusOn(profile).get("profile").get("city").set("Niš");
// .profile is undefined, so .profile.city could not be reached.

A hop before the last one holds undefined, null, or a primitive, so there is nothing to descend into. Only the last hop creates what it names — set, update, push and insert all write where nothing is — and a gap before it cannot be walked through.

Set the intermediate value first, or merge the whole object into place.

It throws, in development only. Carrying on returns the root unchanged, which looks exactly like a write that had nothing to do — see stepping through an optional value for the whole argument. A published build returns the root and says nothing.

ramonda-check reports the same fault before the line runs, as lens-path-through-a-gap: a path through a hop the types declare ?, | null or | undefined, with more path after it. The pair is the point — a gap is the state nobody sets up locally, so the rule speaks for the branch that has not been opened and the code for the one that has.

Next