-
Notifications
You must be signed in to change notification settings - Fork 273
feat: add autocomplete for fireEvent event names #1434
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
feat: add autocomplete for fireEvent event names #1434
Conversation
43c1713
to
5288be0
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1434 +/- ##
==========================================
+ Coverage 97.02% 97.03% +0.01%
==========================================
Files 68 68
Lines 3863 3882 +19
Branches 568 568
==========================================
+ Hits 3748 3767 +19
Misses 115 115
☔ View full report in Codecov by Sentry. |
type StringWithAutoComplete<T> = T | (string & Record<never, never>); | ||
|
||
// String union type of keys of T that start with on, stripped from on | ||
type OnKeys<T> = keyof { |
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.
Nice trick! One think I find disturbing is that it's suggesting uppercase names, e.g. Press
instead of press
. Could you add another step that would make the event name lowercase?
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.
Yes I agree, I updated it so that it's now lowercase
@@ -1,4 +1,10 @@ | |||
import { ReactTestInstance } from 'react-test-renderer'; | |||
import { | |||
ViewProps, | |||
TextProps, |
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.
Let's also add TextInputProps
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.
Awesome PR @pierrezimmermannbam! I plant to release a new RNTL (minor) version tomorrow.
This PR has been released in v12.1.3 🚢 |
Summary
This is an attempt to improve
fireEvent
's DX by adding autocomplete for handler props.fireEvent
still accepts any string so this is not a breaking change but it now also comes with an autocomplete. The autocomplete will propose any prop name fromViewProps
,TextProps
,ScrollViewProps
orPressableProps
that starts with on but without the on. So for instanceMomentumScrollEnd
will be proposed becauseScrollViewProps
has theonMomentumScrollEnd
Test plan
I have tested manually the autocomplete and made sure that
fireEvent
still accepts any string