Skip to content

feat/tschema improvements#68

Merged
solidsnakedev merged 4 commits into
mainfrom
feat/tschema-improvements
Nov 22, 2025
Merged

feat/tschema improvements#68
solidsnakedev merged 4 commits into
mainfrom
feat/tschema-improvements

Conversation

@solidsnakedev
Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings November 22, 2025 00:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the TSchema module with new Literal options for better Union control, simplifies implementation by removing redundant code, and adds comprehensive test coverage.

Key Changes

  • Added LiteralOptions interface with index and flatInUnion options for custom positioning and flattening behavior in unions
  • Removed redundant OneLiteral function, consolidating into the main Literal function with overloaded signatures
  • Optimized collision detection algorithm from O(n²) to O(n) using Map-based tracking
  • Added 7 new round-trip tests covering UndefinedOr, custom indices, flatFields, Variant, TaggedStruct, and flatInUnion combinations

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/evolution/src/core/TSchema.ts Core implementation changes: simplified helper functions, added Literal options, removed OneLiteral, optimized Union collision detection, and improved error handling
packages/evolution/test/TSchema.test.ts Added 7 new comprehensive round-trip tests for previously untested features including UndefinedOr, custom indices, flatFields, Variant, and TaggedStruct
packages/evolution/docs/modules/core/TSchema.ts.md Updated documentation to reflect OneLiteral removal, added LiteralOptions interface documentation, and updated TaggedStruct signature
.changeset/beige-donuts-wish.md Detailed changeset documenting new features, code simplifications, optimizations, and new test coverage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/evolution/src/core/TSchema.ts Outdated
? String(actual)
: JSON.stringify(actual)
const actualType = getTypeName(actual)
const actualStr = typeof actual === "object" ? String(actual) : JSON.stringify(actual)
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actualStr calculation doesn't handle bigints correctly. When actual is a bigint, typeof actual === "object" is false, so it will try JSON.stringify(actual), which throws an error because JSON.stringify cannot serialize bigints.

Consider using the same pattern as getTypeName to handle all types consistently:

const actualStr = typeof actual === "bigint" ? String(actual) : typeof actual === "object" ? String(actual) : JSON.stringify(actual)
Suggested change
const actualStr = typeof actual === "object" ? String(actual) : JSON.stringify(actual)
const actualStr = typeof actual === "bigint"
? String(actual)
: typeof actual === "object"
? String(actual)
: JSON.stringify(actual)

Copilot uses AI. Check for mistakes.
@solidsnakedev solidsnakedev merged commit 7311afb into main Nov 22, 2025
4 checks passed
@solidsnakedev solidsnakedev deleted the feat/tschema-improvements branch November 22, 2025 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants