feat(javascript): report observed export property presence (#1160)
* feat(javascript): report observed export property presence Extend compare_javascript_export_shapes so each retained return variant lists observed property names and each change reports presence independently of value resolution. Complete parent coverage classifies one-sided names as added or removed even when static values stay unknown. Fixes #725 * test(javascript): match unknown export-shape values by availability Nested availability objects include a reason when values stay unresolved. Assert availability through objectContaining so presence-only added and removed rows still verify unknown values. * fix(javascript): preserve uncertain export property presence and locations * fix(javascript): normalize presence and preserve local property coverage * fix(javascript): require present discriminants for return pairing * fix(javascript): normalize retained shapes before comparison * refactor(javascript): share return projection with executable examples * fix(javascript): localize uncertainty for missing mutated slots * fix(javascript): bind advertised export examples to exact artifacts * fix(javascript): keep uncertain property flow as candidates --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
@@ -211,14 +211,33 @@ const flattenValue = (
|
||||
path: string,
|
||||
fields: ProjectedReturnField[],
|
||||
coverage: ProjectedPropertyCoverage[],
|
||||
presence: "present" | "absent" | "unknown-coverage" = "present",
|
||||
): void => {
|
||||
if (presence !== "present") {
|
||||
fields.push({
|
||||
path,
|
||||
presence,
|
||||
state: "unknown",
|
||||
value: null,
|
||||
reason:
|
||||
"reason" in value ? value.reason : "Property presence is uncertain.",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (value.status === "literal") {
|
||||
fields.push({ path, state: "literal", value: value.value, reason: null });
|
||||
fields.push({
|
||||
path,
|
||||
presence,
|
||||
state: "literal",
|
||||
value: value.value,
|
||||
reason: null,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (value.status === "union") {
|
||||
fields.push({
|
||||
path,
|
||||
presence,
|
||||
state: "union",
|
||||
value: [...value.values],
|
||||
reason: null,
|
||||
@@ -237,6 +256,7 @@ const flattenValue = (
|
||||
`${path}/${escapePointer(property.name)}`,
|
||||
fields,
|
||||
coverage,
|
||||
property.presence ?? "present",
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -247,11 +267,30 @@ const flattenValue = (
|
||||
: { path, status: "complete", omitted: 0 },
|
||||
);
|
||||
value.items.forEach((item, index) =>
|
||||
flattenValue(item, `${path}/${String(index)}`, fields, coverage),
|
||||
flattenValue(
|
||||
item,
|
||||
`${path}/${String(index)}`,
|
||||
fields,
|
||||
coverage,
|
||||
value.itemPresence?.[index] ?? "present",
|
||||
),
|
||||
);
|
||||
// Sparse mutation metadata retains uncertain slots without expanding arrays.
|
||||
for (const [index, itemPresence] of Object.entries(
|
||||
value.itemPresence ?? {},
|
||||
)) {
|
||||
if (Number(index) < value.items.length) continue;
|
||||
flattenValue(value, `${path}/${index}`, fields, coverage, itemPresence);
|
||||
}
|
||||
return;
|
||||
}
|
||||
fields.push({ path, state: "unknown", value: null, reason: value.reason });
|
||||
fields.push({
|
||||
path,
|
||||
presence,
|
||||
state: "unknown",
|
||||
value: null,
|
||||
reason: value.reason,
|
||||
});
|
||||
};
|
||||
|
||||
const escapePointer = (value: string): string =>
|
||||
|
||||
Reference in New Issue
Block a user