Skip to content

Fix panel Diagnosis: mapped optionality, array/tuple pinpoints, $type snapshots - #291

Merged
kungfooman merged 10 commits into
mainfrom
fix-ui-diagnosis
Oct 4, 2026
Merged

kungfooman merged 10 commits into
mainfrom
fix-ui-diagnosis

Conversation

@kungfooman

Copy link
Copy Markdown
Owner

Fixes: #290

The anchors example's Diagnosis showed ~50 rows for a single genuine failure (alignment: [0,0] vs Vec2, which tsc also rejects): 45 false missing rows for optional keys plus union/wrong rows for valid arrays and class instances. After this change the same check reports exactly the alignment row. Validation behavior is unchanged (no errors.json sequence moves except one pin now carrying its tag); all of it is explainer/materialization fidelity.

Homomorphic maps keep source optionality. {[P in keyof Merged]: Merged[P]} materialized every property as a bare indexedAccess node, so the differ's isOptionalProp check failed on all absent-but-optional keys. createTypeFromMapping now eagerly resolves indexed access through the validators table (createTypeFromIndexedAccess, registered there to keep the module graph acyclic, silent probe with resolveForExtends fallback), and single-member indexed access returns the member itself instead of a hardcoded optional:false union wrapper — so source flags survive onto the materialized tree for validation and explanation alike.

Array/tuple element pinpoints. The differ had map/set branches but arrays and tuples fell through to one opaque whole-value finding. New diffArrayValue/diffTupleValue (budget, per-index paths, passes() fallback, mirroring map/set) pinpoint data.pos[1]; tuple rest/optional/variadic handling is shared with the validator via newly exported tupleEffective/tupleOptional/expandTupleElements, so the two can never drift.

$type snapshots across messaging. postMessage structured-clones, so class instances arrive as plain data and the panel could no longer tell "was a Color" from "never was one". Posted values are now tagged (tagSnapshot: detect-first, so plain data returns by identity with zero extra clone; cycles safe; never throws), and the differ skips $type keys plus absent Function props on nominally matched snapshots (exact or registered-subclass), while untagged values stay strict and present data is always still diffed.

Verified with 25+ new unit tests (all mutation-bitten both directions), a mapped-optional fixture family (input/output/errors.json, tsc-strict green), and the full npm test + lint gate; the one adjusted pin (typeof-subclass-errors.json) now records the tagged instance.

@kungfooman kungfooman self-assigned this Oct 4, 2026
@kungfooman kungfooman added type assertions Everything related to type assertions. type error reporting Everything related to type error reporting in UI Runtime labels Oct 4, 2026
@kungfooman
kungfooman merged commit c121822 into main Oct 4, 2026
4 checks passed
@kungfooman
kungfooman deleted the fix-ui-diagnosis branch October 5, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Runtime type assertions Everything related to type assertions. type error reporting Everything related to type error reporting in UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix UI diagnosis

1 participant