-
Notifications
You must be signed in to change notification settings - Fork 531
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
fix: tree: make field assignment safer #23053
base: main
Are you sure you want to change the base?
Conversation
@@ -234,10 +236,99 @@ describeHydration( | |||
}) {} | |||
const n = init(HasId, {}); | |||
assert.throws(() => { | |||
// TODO: AB:9129: this should not compile | |||
// @ts-expect-error this should not compile |
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.
This is the test which was tracking the known part of this issue. It now works as expected for non-recursive objects.
@@ -294,9 +294,9 @@ describe("SharedTreeCore", () => { | |||
}); | |||
|
|||
const sf = new SchemaFactory("0x4a6 repro"); | |||
const TestNode = sf.objectRecursive("test node", { | |||
class TestNode extends sf.objectRecursive("test node", { |
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.
This change is not required: I simply made it to get much better compile errors when debugging, and left it so other in the future can continue to have much cleaner errors if this code breaks again.
: never; | ||
|
||
/** | ||
* Suitable for assignment. |
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.
Anything more we can say here?
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.
Code Coverage Summary
↓ packages.dds.tree.src.simple-tree.api:
Line Coverage Change: -0.05% Branch Coverage Change: No change
Metric Name | Baseline coverage | PR coverage | Coverage Diff |
---|---|---|---|
Branch Coverage | 88.76% | 88.76% | → No change |
Line Coverage | 82.28% | 82.23% | ↓ -0.05% |
↑ packages.dds.tree.src.simple-tree:
Line Coverage Change: 0.03% Branch Coverage Change: No change
Metric Name | Baseline coverage | PR coverage | Coverage Diff |
---|---|---|---|
Branch Coverage | 94.07% | 94.07% | → No change |
Line Coverage | 97.23% | 97.26% | ↑ 0.03% |
Baseline commit: cc3fb6d
Baseline build: 306250
Happy Coding!!
Code coverage comparison check passed!!
⯅ @fluid-example/bundle-size-tests: +245 Bytes
Baseline commit: cc3fb6d |
Co-authored-by: Joshua Smithrud <[email protected]>
I missed a case in the implementation. It does not handler optional fields very well. Also looking at possible usage, I think this change should be paired with a new API, maybe That would provide an option with typing that matches |
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.
Copilot reviewed 5 out of 17 changed files in this pull request and generated no suggestions.
Files not reviewed (12)
- packages/dds/tree/api-report/tree.legacy.public.api.md: Evaluated as low risk
- packages/dds/tree/api-report/tree.alpha.api.md: Evaluated as low risk
- .changeset/metal-sloths-join.md: Evaluated as low risk
- packages/dds/tree/src/index.ts: Evaluated as low risk
- packages/dds/tree/src/simple-tree/index.ts: Evaluated as low risk
- packages/dds/tree/src/test/shared-tree-core/sharedTreeCore.spec.ts: Evaluated as low risk
- packages/framework/fluid-framework/api-report/fluid-framework.beta.api.md: Evaluated as low risk
- packages/framework/fluid-framework/api-report/fluid-framework.public.api.md: Evaluated as low risk
- packages/framework/fluid-framework/api-report/fluid-framework.legacy.public.api.md: Evaluated as low risk
- packages/dds/tree/api-report/tree.legacy.alpha.api.md: Evaluated as low risk
- packages/dds/tree/src/simple-tree/api/typesUnsafe.ts: Evaluated as low risk
- packages/framework/fluid-framework/api-report/fluid-framework.legacy.alpha.api.md: Evaluated as low risk
Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more
🔗 No broken links found! ✅ Your attention to detail is admirable. linkcheck output
|
Description
Fixes two typing issues related to assignment of fields.
One issue is tracked by AB:9129
See changeset for details.
Breaking Changes
It's possible that an application relied on this unsafety to assign to fields with non-exact schema. This is unlikely since creating such nodes is not allowed by the types already.
Assignment of identifier fields unconditionally errors at runtime, so it is unlikely anyone depended on that compiling.
Reviewer Guidance
The review process is outlined on this wiki page.