-
Notifications
You must be signed in to change notification settings - Fork 567
feat: customizeSchemaTyping #23084
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
feat: customizeSchemaTyping #23084
Changes from all commits
8c91051
aea7d62
73d05f5
ec64de4
395c688
4119174
a90e167
90a79f5
494dde2
6997880
735622f
a1c3bd0
beffae5
2836d9b
7ebff45
1dcd254
eb49097
10c5ef8
9645aa6
2a91ad2
a3981a8
773afb9
d7cf0e5
cc2684a
ec90211
b3dffdc
6e4faa2
a6df85c
14893ad
bdc6959
86a4b5d
8ab3281
addb022
91fe629
3b33fea
224c7b5
9e1328b
b1b2c41
23487bf
13beb5e
3da123f
41d2c5c
d8681cb
ff69090
94b9178
89a5756
1828f00
bbb0ef6
fbe06f6
77b0e2f
9a2c09c
fa17c25
73fa9dc
951d9ce
3096691
24cf057
2b51d0d
a956b61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --- | ||
| "fluid-framework": minor | ||
| "@fluidframework/tree": minor | ||
| --- | ||
| --- | ||
| "section": tree | ||
|
Check failure on line 6 in .changeset/metal-sloths-join.md
|
||
| --- | ||
|
|
||
| Disallow some invalid and unsafe ObjectNode field assignments at compile time | ||
|
|
||
| The compile time validation of the type of values assigned to ObjectNode fields is limited by TypeScript's limitations. | ||
| Two cases which were actually possible to disallow and should be disallowed for consistency with runtime behavior and similar APIs were being allowed: | ||
|
|
||
| 1. [Identifier fields](https://fluidframework.com/docs/api/v2/fluid-framework/schemafactory-class#identifier-property): | ||
| Identifier fields are immutable, and setting them produces a runtime error. | ||
| This changes fixes them to no longer be typed as assignable. | ||
|
|
||
| 2. Fields with non-exact schema: | ||
| When non-exact scheme is used for a field (for example the schema is either a schema only allowing numbers or a schema only allowing strings) the field is no longer typed as assignable. | ||
| This matches how constructors and implicit node construction work. | ||
| For example when a node `Foo` has such an non-exact schema for field `bar`, you can no longer unsafely do `foo.bar = 5` just like how you could already not do `new Foo({bar: 5})`. | ||
|
|
||
| This fix only applies to [`SchemaFactory.object`](https://fluidframework.com/docs/api/v2/fluid-framework/schemafactory-class#object-method). | ||
| [`SchemaFactory.objectRecursive`](https://fluidframework.com/docs/api/v2/fluid-framework/schemafactory-class#objectrecursive-method) was unable to be updated to match due to TypeScript limitations on recursive types. | ||
|
|
||
| An `@alpha` API, `customizeSchemaTyping` has been added to allow control over the types generated from schema. | ||
| For example code relying on the unsound typing fixed above can restore the behavior using `customizeSchemaTyping`: | ||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
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 PR builds upon #23053 . This changeset will probably need to be rewritten based on the major changes.