Support recursive annotated and staged types#25199
Support recursive annotated and staged types#25199CraigMacomber merged 22 commits intomicrosoft:mainfrom
Conversation
…to RecursiveAnnotations
…to RecursiveAnnotations
…to RecursiveAnnotations
…to RecursiveAnnotations
…to RecursiveAnnotations
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for recursive annotated and staged types to the schema system. The changes introduce new "unsafe" type utilities and recursive variants of existing APIs that can handle recursive type definitions where the standard TypeScript type system has limitations.
Key changes:
- Adds new
*Unsafetype variants that useUnenforcedconstraints to work around TypeScript recursion limitations - Introduces
stagedRecursiveandtypesRecursivemethods to SchemaFactoryAlpha for handling recursive schema definitions - Provides comprehensive test coverage for the new recursive type APIs
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/framework/fluid-framework/api-report/fluid-framework.alpha.api.md |
Adds API surface for new unsafe type utilities and recursive methods |
packages/dds/tree/api-report/tree.alpha.api.md |
Mirrors the API changes for the tree package |
packages/dds/tree/src/simple-tree/api/typesUnsafe.ts |
Implements core unsafe type utilities for recursive schema support |
packages/dds/tree/src/simple-tree/api/schemaFactoryAlpha.ts |
Adds stagedRecursive and typesRecursive methods to SchemaFactoryAlpha |
packages/dds/tree/src/simple-tree/api/schemaStatics.ts |
Documents the unsafe field schema creation utility |
packages/dds/tree/src/test/simple-tree/core/allowedTypes.spec.ts |
Adds test coverage for type annotation utilities |
packages/dds/tree/src/test/simple-tree/api/typesUnsafe.spec.ts |
Tests the new unsafe type utilities |
packages/dds/tree/src/test/simple-tree/api/schemaStatics.spec.ts |
Tests schema statics functionality |
packages/dds/tree/src/test/simple-tree/api/schemaFactoryRecursive.spec.ts |
Comprehensive test suite for recursive schema features |
| Multiple index files | Export the new unsafe types and utilities |
| assert.deepEqual([...r.r], []); | ||
| }); | ||
|
|
||
| describe("typesRecursive", () => { |
There was a problem hiding this comment.
Here is the main test suit for the new APIs: rest of the test changes are mostly incidental from a lot of experiments, but worth keeping.
| * If all inputs (at least recursive ones) were required to be annotated, this could be typed more strongly. | ||
| * In that case it could use `T extends readonly (AnnotatedAllowedTypeUnsafe | LazyItem<System_Unsafe.TreeNodeSchemaUnsafe>)[]`. |
There was a problem hiding this comment.
Is this something we want to do or just a note for later? feels like it'll be easily lost
There was a problem hiding this comment.
This is just a note for if someone comes to fiddle with this APi in the future to try and make it more type safe to save them a couple hours of experimenting that I already did.
Co-authored-by: Jenn <jennle@microsoft.com>
|
🔗 Found some broken links! 💔 Run a link check locally to find them. See linkcheck output |
## Description Add support for recursive annotated and staged types.
Description
Add support for recursive annotated and staged types.
Reviewer Guidance
The review process is outlined on this wiki page.