Typed property access
# grade this stage (from your course directory)
npx theinference test --stage property-access --watchA graph database is only useful if you can read attributes back with the right type. Implement getProperty(kind, id, key): look up the entity, return props[key] with its native type, or null when the key is missing. Graphs are schema-flexible — not every Person has born, and no Movie has a director property (that's a relationship, not an attribute).
Implement getProperty
Return the value with its native type, or null for an absent key. Distinguish null (absent) from a property that genuinely holds another value. The getprop CLI command reads three keys off The Matrix (id 66): title (string), released (int), and director (absent → null).
getProperty(kind: "node" | "rel", id: number, key: string): Value | null {
const entity = kind === "node" ? this.nodeById.get(id) : this.relById.get(id);
if (!entity) return null;
const v = entity.props[key];
return v === undefined ? null : v;
}
your_program.sh getprop {fixture}/fixtures/data/nodes.json {fixture}/fixtures/data/relationships.json node 66 title released director
# -> ["The Matrix", 1999, null]
Process mode, stdout_json_match against ["The Matrix", 1999, null]. The comparison is type-sensitive: 1999 !== "1999", and null is not the same as a missing element. Return the integer as a number and the absent key as JSON null.