-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[core-data]: Fix TS types for user object #68045
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
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in 8de2b23. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17725084572
|
Mamaduka
left a comment
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.
Sorry for the late reply, @manzoorwanijk!
The changes make sense. The REST API will use the default context view when the query argument isn't specified. The entities set the default context as part of baseURLParams, but that's not the case for the current user resolver.
This PR solves two issues
getCurrentUserselector's return type is set toET.User< 'edit' >, which sets the incorrect return type with properties that don't exist on the current user object, for example,user.capabilities. The return type should rather beET.User< 'view' >because that is whatstate.currentUseris, as mentioned in Convert core-data selectors from jsDoc annotations into TypeScript type signatures #40025 (comment)Here, you can see the difference between a current user (
users/me) and a normal user (users/<id>) object.user.capabilitiesis set toRecord< string, string >, which is incorrect. It should rather beRecord< string, boolean >, because those capabilities come from here as pointed out in Core Data: TypeScript definitions for entity records. #38666 (comment)What?
getCurrentUserselector.user.capabilitiesto be a record of booleans instead of a record of strings.Why?
To fix the incorrect types
How?
By fixing the types
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast