You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However its behaviour is not ideal in practice when consuming entries from a partial type (that has optional values) owing to...
the use of keyof which is systematically too broad
allowing through a partial value type, when optionality makes no sense for a entry which has been found in an object
In particular, undefined values and undefined entries are permitted through.
Expected behavior
ObjectEntry should reflect possible values from an object with optional properties (which is to say if there is an entry, it is populated, and that entries themselves cannot be undefined).
The
ObjectEntry
type is intended to help with consuming the pairs fromObject.entries
. It is currently implemented as...However its behaviour is not ideal in practice when consuming entries from a partial type (that has optional values) owing to...
keyof
which is systematically too broadIn particular, undefined values and undefined entries are permitted through.
Expected behavior
ObjectEntry should reflect possible values from an object with optional properties (which is to say if there is an entry, it is populated, and that entries themselves cannot be undefined).
You can see an errored case of the current implementation, and a fixed implementation
TypedEntryOf
in the playground at https://www.typescriptlang.org/play?ts=5.3.2#code/C4TwDgpgBA8gRgKwgY2AUQHbAE4gDwAqAfFALxQDeUA2gNJQCWGUA1hCAPYBmUBAugC4atADS86fPlAC+1Npx78A3AFgAUOtCRe4CABNa7GF0IlyBKBAAewCBj0BnKAAUAhtmANXAGzxMuENhQAEokAPxQABTBljZ2jiEoHNh6fhgBQaJQAK4YLBgcAO4Y4VD0QhgQAG6BAJRQFdWBqmpa0AS6epg4IMamZJTCjMwdkAZGJsSCwmLBEACO2QzY+qYSUrKj+oa9k0R8LZq6Lt6ulcAAMhwcLNlgAxTqUFAAFhDe3hxhQgDkhcnePQ-FrPF4Mb5QH4AW3cDmB6mkhzUyA4GAcwCgnxudyEzlO5yu2Pu5EealB70+v3+2EBPxET1eDF+MOwcPpamkUFcThRaOASLaUDQVlcULA3ggWy6WFwxgGUu6spMbW4mOutzARBaAHptc8AHphdRHbTC0XiiDwJCoRUgAZWlDoGX4FU8LEarXqXUGo0aNRAAActual behavior
Undefined values creep in at multiple levels
Steps to reproduce
See provided playground
Suggested solution?
A preferred implementation is shown below...
What version of
emery
are you running?Latest at the time of writing
Demo
The text was updated successfully, but these errors were encountered: