Repository navigation
Preserve collection toJSON return types - #242
Merged
Merged
Conversation
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.
Direct
ArraySchema.toJSON()andMapSchema.toJSON()calls currently returnany[]andany, allowing invalid assignments and losing the serialized element shape in typed UI state.Annotate the existing methods with arrays/string-keyed records of each element's inferred
toJSON()return type, or the element type when it has no serializer. This preserves primitive and literal values, recursively serialized Schema data, and customtoJSON()overrides. Keep the existingToJSONutility, Schema/assign behavior, and runtime implementation unchanged.Extend the strict emitted-declaration fixtures with positive and negative checks for primitive values, codec-named string literals, Schema data versus class methods, nested/custom serialization, union/default values, recursive collections, and native collection interfaces. The latter two cover the compatibility problems discussed in #174.
Validation on Node.js 20 and 24:
npm test: 1,043 passing, one existing pending; all six TypeScript 5/7 compiler configurations pass.npm run buildandnpm run test:exportspass.Fixes #162