Skip to content

Support recursive annotated and staged types#25199

Merged
CraigMacomber merged 22 commits intomicrosoft:mainfrom
CraigMacomber:RecursiveAnnotations
Oct 8, 2025
Merged

Support recursive annotated and staged types#25199
CraigMacomber merged 22 commits intomicrosoft:mainfrom
CraigMacomber:RecursiveAnnotations

Conversation

@CraigMacomber
Copy link
Contributor

@CraigMacomber CraigMacomber commented Aug 12, 2025

Description

Add support for recursive annotated and staged types.

Reviewer Guidance

The review process is outlined on this wiki page.

@github-actions github-actions bot added area: dds Issues related to distributed data structures area: dds: tree base: main PRs targeted against main branch labels Aug 12, 2025
@github-actions github-actions bot added the public api change Changes to a public API label Oct 8, 2025
@github-actions github-actions bot added the area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct label Oct 8, 2025
@CraigMacomber CraigMacomber changed the title Try and make recursive annotated types work Support recursive annotated and staged types Oct 8, 2025
@CraigMacomber CraigMacomber marked this pull request as ready for review October 8, 2025 19:17
@CraigMacomber CraigMacomber requested a review from a team as a code owner October 8, 2025 19:17
Copilot AI review requested due to automatic review settings October 8, 2025 19:17
Copy link
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 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 *Unsafe type variants that use Unenforced constraints to work around TypeScript recursion limitations
  • Introduces stagedRecursive and typesRecursive methods 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", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@CraigMacomber CraigMacomber requested a review from a team as a code owner October 8, 2025 19:33
Comment on lines +141 to +142
* 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>)[]`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something we want to do or just a note for later? feels like it'll be easily lost

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 8, 2025

🔗 Found some broken links! 💔

Run a link check locally to find them. See
https://github.com/microsoft/FluidFramework/wiki/Checking-for-broken-links-in-the-documentation for more information.

linkcheck output


> fluid-framework-docs-site@0.0.0 ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> fluid-framework-docs-site@0.0.0 serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> fluid-framework-docs-site@0.0.0 check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

 ELIFECYCLE  Command failed with exit code 1.

Copy link
Contributor

@alexvy86 alexvy86 left a comment

Choose a reason for hiding this comment

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

Approving for docs.

@CraigMacomber CraigMacomber merged commit 931e986 into microsoft:main Oct 8, 2025
38 checks passed
@CraigMacomber CraigMacomber deleted the RecursiveAnnotations branch October 8, 2025 23:51
anthony-murphy-agent pushed a commit to anthony-murphy-agent/FluidFramework that referenced this pull request Jan 14, 2026
## Description

Add support for recursive annotated and staged types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: dds: tree area: dds Issues related to distributed data structures area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct base: main PRs targeted against main branch changeset-present public api change Changes to a public API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants