-
Notifications
You must be signed in to change notification settings - Fork 3
test: add tschema recursive example #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 adds comprehensive test coverage for recursive TSchema structures using a MultisigScript example adapted from the Aiken blockchain language. The tests demonstrate how to define and use recursive union types with TSchema, including proper use of Schema.suspend() for handling forward references.
Key Changes:
- Adds new test file
TSchema.recursive.test.tswith 11 test cases covering recursive schema structures - Demonstrates recursive union types with nested array fields using
Schema.suspend() - Tests various nesting depths and edge cases (empty arrays, complex multi-level structures)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| | { readonly Script: { readonly scriptHash: Uint8Array } } | ||
|
|
||
| // Define the recursive MultisigScript schema | ||
| const MultisigScriptSchema = TSchema.Union( |
Copilot
AI
Dec 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are extra spaces between the variable name and the equals sign. This should be a single space for consistency with TypeScript formatting conventions.
| const MultisigScriptSchema = TSchema.Union( | |
| const MultisigScriptSchema = TSchema.Union( |
| { | ||
| AllOf: TSchema.Struct( | ||
| { | ||
| scripts: TSchema.Array(Schema.suspend(() : Schema.Schema<MultisigScript, Data.Constr> => MultisigScriptSchema)), |
Copilot
AI
Dec 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type annotation has extra spacing between the colon and Schema.Schema. The spacing should be consistent with TypeScript conventions (single space after colon).
| { | ||
| AnyOf: TSchema.Struct( | ||
| { | ||
| scripts: TSchema.Array(Schema.suspend(() : Schema.Schema<MultisigScript, Data.Constr> => MultisigScriptSchema)), |
Copilot
AI
Dec 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type annotation has extra spacing between the colon and Schema.Schema. The spacing should be consistent with TypeScript conventions (single space after colon).
| AtLeast: TSchema.Struct( | ||
| { | ||
| required: TSchema.Integer, | ||
| scripts: TSchema.Array(Schema.suspend(() : Schema.Schema<MultisigScript, Data.Constr> => MultisigScriptSchema)), |
Copilot
AI
Dec 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type annotation has extra spacing between the colon and Schema.Schema. The spacing should be consistent with TypeScript conventions (single space after colon).
No description provided.