Skip to content
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: Empty ObjectNode type safety #23162

Merged
merged 4 commits into from
Nov 20, 2024
Merged

Conversation

CraigMacomber
Copy link
Contributor

Description

ObjectNodes with no fields will now emit a compiler error if constructed from an object literal with fields.
This matches the behavior of non-empty ObjectNodes which already gave errors when unexpected properties were provided.

Also adds an "unsound union properties" test demoing a type soundness issue which impacts tree but is a limitation of TypeScript which Tree can no workaround.

Breaking Changes

Any code which constructed object nodes with no fields from object literals with fields should have those fields removed as they have no impact at runtime.

Reviewer Guidance

The review process is outlined on this wiki page.

@CraigMacomber CraigMacomber requested review from a team as code owners November 20, 2024 19:31
@github-actions github-actions bot added area: dds Issues related to distributed data structures area: dds: tree area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct public api change Changes to a public API base: main PRs targeted against main branch labels Nov 20, 2024
Copy link
Collaborator

@msfluid-bot msfluid-bot left a comment

Choose a reason for hiding this comment

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

Code Coverage Summary

No packages impacted by the change.


Baseline commit: 9a8f69a
Baseline build: 308718
Happy Coding!!

Code coverage comparison check passed!!

@msfluid-bot
Copy link
Collaborator

msfluid-bot commented Nov 20, 2024

@fluid-example/bundle-size-tests: +245 Bytes
Metric NameBaseline SizeCompare SizeSize Diff
aqueduct.js 467.24 KB 467.27 KB +35 Bytes
azureClient.js 564.01 KB 564.06 KB +49 Bytes
connectionState.js 724 Bytes 724 Bytes No change
containerRuntime.js 263.43 KB 263.45 KB +14 Bytes
fluidFramework.js 428.31 KB 428.32 KB +14 Bytes
loader.js 134.18 KB 134.19 KB +14 Bytes
map.js 42.71 KB 42.71 KB +7 Bytes
matrix.js 150.15 KB 150.16 KB +7 Bytes
odspClient.js 529.85 KB 529.89 KB +49 Bytes
odspDriver.js 97.88 KB 97.9 KB +21 Bytes
odspPrefetchSnapshot.js 42.81 KB 42.83 KB +14 Bytes
sharedString.js 166.23 KB 166.24 KB +7 Bytes
sharedTree.js 418.76 KB 418.77 KB +7 Bytes
Total Size 3.38 MB 3.38 MB +245 Bytes

Baseline commit: 9a8f69a

Generated by 🚫 dangerJS against 0631ae5

@CraigMacomber CraigMacomber changed the title Empty ObjectNodes safety Empty ObjectNode type safety Nov 20, 2024
Copy link
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> [email protected] 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"


> [email protected] serve
> docusaurus serve --no-open

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

> [email protected] check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  170005 links
    1595 destination URLs
    1825 URLs ignored
       0 warnings
       0 errors


@CraigMacomber CraigMacomber changed the title Empty ObjectNode type safety fix: Empty ObjectNode type safety Nov 20, 2024
Copy link
Contributor

@Josmithr Josmithr left a comment

Choose a reason for hiding this comment

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

Left a couple of questions but overall, this looks like a great safety improvement!

@CraigMacomber CraigMacomber merged commit dc3c300 into microsoft:main Nov 20, 2024
43 checks passed
@CraigMacomber CraigMacomber deleted the unionTest branch November 20, 2024 21:52
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.

3 participants