-
Notifications
You must be signed in to change notification settings - Fork 37.2k
fix(chat): guard against undefined customModes.custom Fix #272223 and #272236 #272263
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
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.
Pull Request Overview
This PR fixes a runtime error by adding a defensive guard against undefined customModes.custom. The change prevents potential crashes when the custom property is not defined.
|
Thanks for the contribution |
|
@lramos15 do we have a type problem though, why was this not discovered previously? |
|
I'll defer to @roblourens since this is his code (I just merged this to unblock the broken picker), but looks like this regressed with #272197. Funny enough Copilot code review caught this #272197 (comment) |
|
Thanks @tamuratak! This is apparently an issue with the type definition of |
The thing is that the first part of the comment |
See #272263, it currently assumes that all keys of K will be defined. This still isn't perfect, because it says that the returned object might contain a key with value `undefined`, but in reality, if a key is defined, it will have a value. So now usages of this with Object.entries and so on are slighly wrong, but that's preferable IMO.
See #272263, it currently assumes that all keys of K will be defined. This still isn't perfect, because it says that the returned object might contain a key with value `undefined`, but in reality, if a key is defined, it will have a value. So now usages of this with Object.entries and so on are slighly wrong, but that's preferable IMO.
Guard against undefined customModes.custom. Fix #272223 and #272236