Repository navigation
fix(core): Type controller.set() values by schema #4133
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
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
12148e0
fix(core): Type controller.set() values by schema
claude 79cf14a
enhance(core): Simplify controller.set() value types
claude aeeb1ec
Merge remote-tracking branch 'origin/master' into claude/project-thre…
claude ff16929
Merge remote-tracking branch 'origin/master' into claude/project-thre…
claude b03b648
enhance(core): Speed up controller.set() value type checking
claude 113032d
Merge origin/master into claude/project-thread-jjim10
claude 303c6ea
fix(core): Unwrap nested Queries in set() value types; document Union…
claude 4acdb67
Merge origin/master into claude/project-thread-jjim10
claude 0907ba1
docs(blog): Interactive demo of typed controller.set() values
claude e196894
docs(blog): Move typed set() section under Other improvements
claude 6b0d942
Merge origin/master into claude/project-thread-jjim10
claude 4b9134f
Merge origin/master into claude/project-thread-jjim10
claude 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,22 @@ | ||
| --- | ||
| '@data-client/core': patch | ||
| '@data-client/react': patch | ||
| '@data-client/vue': patch | ||
| --- | ||
|
|
||
| Fix `controller.set()` accepting any value | ||
|
|
||
| Values are now typed by the schema: Entities take their fields, while [Collection](https://dataclient.io/rest/api/Collection) | ||
| and [All](https://dataclient.io/rest/api/All) take a list of rows. [Query](https://dataclient.io/rest/api/Query) takes | ||
| the input of the schema it wraps, not what its `process()` returns. Updater functions must return the same. | ||
|
|
||
| ```ts | ||
| // Before: these all typechecked, then failed or wrote nothing at runtime | ||
| ctrl.set(new schema.All(Todo), 42); | ||
| ctrl.set(TodoResource.getList.schema, 'anything'); | ||
| ctrl.set(Todo, { id: '5' }, { id: '5', completed: 'yes' }); | ||
|
|
||
| // After: TypeScript errors on the above; these typecheck | ||
| ctrl.set(TodoResource.getList.schema, [{ id: '5', completed: true }]); | ||
| ctrl.set(new schema.All(Todo), [{ id: '5', completed: true }]); | ||
| ``` |
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
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
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.
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.