Skip to content

refactor(tree): Leverage schema type-narrowing helper functions #24909

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

Merged

Conversation

Josmithr
Copy link
Contributor

Replaces some explicit node.kind equality checks with existing type-narrowing helpers.

@Josmithr Josmithr requested a review from a team as a code owner June 24, 2025 23:20
@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 Jun 24, 2025
Copy link
Contributor

@Copilot 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 refactors schema-kind checks by leveraging existing type-narrowing helper functions instead of direct node.kind comparisons.

  • Replaced all explicit schema.kind === NodeKind.* checks with is*NodeSchema(schema) and added corresponding assert calls.
  • Updated function signatures (arrayToFlexContent, mapToFlexContent, objectToFlexContent) to accept specific schema types.
  • Consolidated imports of schema type guards and disabled internal-module linting around them.

Reviewed Changes

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

File Description
packages/dds/tree/src/simple-tree/unhydratedFlexTreeFromInsertable.ts Swapped kind checks for is*NodeSchema asserts; tightened helper signatures and reorganized imports
packages/dds/tree/src/simple-tree/api/treeNodeApi.ts Changed array-kind branch to use isArrayNodeSchema instead of NodeKind.Array
packages/dds/tree/src/simple-tree/api/customTree.ts Replaced NodeKind.Array check with isArrayNodeSchema
packages/dds/tree/src/simple-tree/api/configuration.ts Updated union validation to use isArrayNodeSchema/isMapNodeSchema and refined typed arrays/maps

@Josmithr Josmithr enabled auto-merge (squash) June 25, 2025 00:10
@Josmithr Josmithr merged commit 72340a9 into microsoft:main Jun 25, 2025
33 checks passed
@Josmithr Josmithr deleted the tree/use-schema-type-narrowing-helpers branch June 25, 2025 17:16
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 base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants