-
Notifications
You must be signed in to change notification settings - Fork 548
Name collisions from structurally named schema now error #24707
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
CraigMacomber
merged 13 commits into
microsoft:main
from
CraigMacomber:structurallyCollide
May 27, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
036523e
Name collisions from structurally named schema now error
CraigMacomber c690e94
Update .changeset/social-bears-deny.md
CraigMacomber 718bc3d
Update packages/dds/tree/src/test/simple-tree/api/schemaFactory.spec.ts
CraigMacomber fea4ab0
Apply suggestions from code review
CraigMacomber a3fd11b
Update .changeset/social-bears-deny.md
CraigMacomber e839c60
Update packages/dds/tree/src/simple-tree/api/schemaFactory.ts
CraigMacomber ac42833
Update message
CraigMacomber 9019773
Update .changeset/social-bears-deny.md
CraigMacomber 38e857d
Add a comment
CraigMacomber 0f27231
Merge branch 'structurallyCollide' of https://github.com/CraigMacombe…
CraigMacomber a0604e2
Merge branch 'main' into structurallyCollide
CraigMacomber 498144d
Remove invalid link suggested by copilot, and correct details of doc …
CraigMacomber e709ec8
Merge branch 'main' into structurallyCollide
CraigMacomber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
"@fluidframework/tree": minor | ||
"fluid-framework": minor | ||
"__section": tree | ||
--- | ||
Name collisions from structurally named schema now error | ||
|
||
It is legal to have multiple [TreeNodeSchema](https://fluidframework.com/docs/api/fluid-framework/treenodeschema-typealias) with the same name so long as they are not used together in the same tree. | ||
Using different schema with the same name when building otherwise identical [structurally named](https://fluidframework.com/docs/api/fluid-framework/schemafactory-class#schemafactory-remarks) in the same [SchemaFactory](https://fluidframework.com/docs/api/fluid-framework/schemafactory-class) is not valid, however. | ||
Previously doing this would not error, and instead return the first structurally named schema with that name. | ||
Now this case throws an informative error: | ||
|
||
```typescript | ||
const factory = new SchemaFactory(undefined); | ||
class Child1 extends factory.object("Child", {}) {} | ||
class Child2 extends factory.object("Child", {}) {} | ||
|
||
const a = factory.map(Child1); | ||
|
||
// Throws a UsageError with the message: | ||
// "Structurally named schema collision: two schema named "Array<["Child"]>" were defined with different input schema." | ||
const b = factory.array(Child2); | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.