-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Feature Request: Allow nullish values to omit event handlers #7568
Comments
@dummdidumm I think this would be a |
Yes this needs a adjustment in language tools. This is already allowed for Dom events but not component events |
Thanks, @Conduitry and @dummdidumm! |
@Conduitry was about to implement this and tested it out in the REPL one more time, and noticed that this isn't implemented for component events. If I do |
This should be supported now as of 3.51.0. |
Is there a way to re-enable the strict mode? ^^' |
Describe the problem
Most props can be excluded in this sort of fashion:
However, this does not work for event handlers (at least in TS setups) due to the expected TypeScript type
(e: MouseEvent) => any
.Describe the proposed solution
I propose setting up event handlers in such a way that they support the types
null | undefined
as well as(e: MouseEvent) => any
and that in the case ofnull | undefined
, the handler be excluded from the element/component instance.Alternatives considered
Currently, to work around this, I am using an "empty" function with nullish coalescing. This won't kill site performance by any means, but firing a pointless function like this is not the ideal workaround.
Here is an example of my current setup:
Importance
would make my life easier
The text was updated successfully, but these errors were encountered: