Fix panel Diagnosis: mapped optionality, array/tuple pinpoints, $type snapshots - #291
Merged
Merged
Conversation
# Conflicts: # src-runtime/createTypeFromMapping.js # src-runtime/index.js # test_runtime.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #290
The anchors example's Diagnosis showed ~50 rows for a single genuine failure (
alignment: [0,0]vsVec2, which tsc also rejects): 45 falsemissingrows for optional keys plusunion/wrongrows for valid arrays and class instances. After this change the same check reports exactly the alignment row. Validation behavior is unchanged (noerrors.jsonsequence 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 bareindexedAccessnode, so the differ'sisOptionalPropcheck failed on all absent-but-optional keys.createTypeFromMappingnow eagerly resolves indexed access through the validators table (createTypeFromIndexedAccess, registered there to keep the module graph acyclic, silent probe withresolveForExtendsfallback), and single-member indexed access returns the member itself instead of a hardcodedoptional:falseunion 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) pinpointdata.pos[1]; tuple rest/optional/variadic handling is shared with the validator via newly exportedtupleEffective/tupleOptional/expandTupleElements, so the two can never drift.$typesnapshots across messaging.postMessagestructured-clones, so class instances arrive as plain data and the panel could no longer tell "was aColor" 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$typekeys plus absentFunctionprops 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-optionalfixture family (input/output/errors.json, tsc-strict green), and the fullnpm test+lintgate; the one adjusted pin (typeof-subclass-errors.json) now records the tagged instance.