-
Notifications
You must be signed in to change notification settings - Fork 338
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 compiler error "does not satisfy the constraint 'ObjectNested'" #5607
Conversation
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.
Looks good, thanks for the update 🙌🏻
It makes sense to describe the ConfigurationType
received by the functions that receive a configuration from the markup or component constructor with Partial<Record<keyof ConfigurationType, unknown>>
as it's more representative of the expected situation.
Only one little stylistic suggestion for that for
loop in normaliseDataset
which is a bit heavy with the casting in the middle of it, would be great to have that as a variable before the loop. I'll approve in the meantime.
for (const entries of /** @type {[keyof ConfigurationType, SchemaProperty | undefined][]} */ ( | ||
Object.entries(Component.schema.properties) | ||
)) { | ||
const [namespace, property] = entries | ||
const field = namespace.toString() |
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.
Recording what we understood during the review
namespace
is akeyof ConfigurationType
which will be passed toextractConfigByNamespace
which also requires akeyof ConfigurationType
field
needs to be a string so it can be used to accessdataset
(aDOMStringMap
and fillout
(anObjectNested
, whose keys arestring
)
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.
suggestion Having the casting outside of the for
loop would increase readability:
for (const entries of /** @type {[keyof ConfigurationType, SchemaProperty | undefined][]} */ ( | |
Object.entries(Component.schema.properties) | |
)) { | |
const [namespace, property] = entries | |
const field = namespace.toString() | |
const entries = /** @type {[keyof ConfigurationType, SchemaProperty | undefined][]} */ ( | |
Object.entries(Component.schema.properties) | |
) | |
for (const entry of entries) { | |
const [namespace, property] = entry | |
// Cast the `namespace` to string so it can be used to access the dataset | |
const field = namespace.toString() |
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.
Thanks @romaricpascal @domoscargin
Just pushed. How's this? ab3d188
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.
LGTM - running checks now
ab3d188
to
bae36c8
Compare
Thanks @colinrotherham! |
This PR fixes #5606
Affects
ConfigurableComponent<CustomConfig>
in v5.8.0 whereCustomConfig
doesn't extendObjectNested
I've shared the config type via
Schema
Schema<ConfigurationType>
for use in@param
and@returns
tooThis may not have affected JSDoc due to The Empty Object Type in TypeScript