fix(xychart): strip legacy react events from exhaustive prop lists in type declarations#1841
Open
mtlewis wants to merge 1 commit intoairbnb:masterfrom
Open
fix(xychart): strip legacy react events from exhaustive prop lists in type declarations#1841mtlewis wants to merge 1 commit intoairbnb:masterfrom
mtlewis wants to merge 1 commit intoairbnb:masterfrom
Conversation
… type declarations The event names `onPointerEnterCapture` and `onPointerLeaveCapture` are erroneously included in the types for react 16 and 17 - these have never been valid event names, but the decision has been taken to leave them in place based on the definitely-typed backporting policy. However, these event names _have_ been removed from the types for React 18. In a few places in xycharts, properties are removed from components with DOM element props using the `Omit` utility type. When the declarations are generated, these `Omit`s are transformed into `Pick`s with the inverted set of keys. This results in all known properties for these components (including `onPointerEnterCapture` and `onPointerLeaveCapture`) being included. This causes compilation errors for consumers of this package that use React 18. This commit proposes a heavily targeted fix by including the removed event names in the string unions passed to `Omit`. This is somewhat distasteful, because it only resolves the issue for existing occurrences - any new places in the codebase with this pattern will need to be specifically handled. Possible future improvements: 1. Test the type declarations in this library against the React 18 types in CI to ensure we handle future occurrences of this pattern. 2. Find a general solution to this. The only possibility I can come up with is patching the react type declarations used in this library to remove these events - since they aren't valid anyway, it should be fine to remove them.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🐛 Bug Fix
The event names
onPointerEnterCaptureandonPointerLeaveCaptureare erroneously included in the types for React 16 and 17 - these have never been valid event names, but the decision has been taken to leave them in place based on the definitely-typed backporting policy. However, these event names have been removed from the types for React 18.In a few places in xycharts, properties are removed from components with DOM element props
using the
Omitutility type. When the declarations are generated, theseOmits are transformed intoPicks with the inverted set of keys. This results in all known properties for these components (includingonPointerEnterCaptureandonPointerLeaveCapture) being included. This causes compilation errors for consumers of this package that use React 18.This commit proposes a heavily targeted fix by including the removed event names in the string unions passed to
Omit. This is somewhat distasteful, because it only resolves the issue for existing occurrences - any new places in the codebase with this pattern will need to be specifically handled.Possible future improvements