-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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: warn on unused result #17282
Comments
This is my same struggle #13376 |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
Can this be re-opened? I think having a "warn_on_unused" annotation is actually different than #13376. There are plenty of non-async cases where you'd want to be warned about an unused result, for instance with redux. const someActionCreator = (payload: string) => ({
type: SOME_ACTION,
payload
});
const someAction = () => (dispatch) => {
// Compute the payload...
const payload = 'foo.bar';
// The correct way:
// dispatch(someActionCreator(payload));
// What can easily happen:
someActionCreator(payload);
};
const onTouchTarget = () => this.props.dispatch(someAction()); This could be solved a number of ways, but a decorator seems pretty natural: @warn_unused_result
const someActionCreator = (payload: string): => ({
type: SOME_ACTION,
payload
}); |
There's another issue I can't find at the moment that covers non-discardable function return values |
tracked now by #8584 |
It can be easy to forget an
await
for a method returningPromise<void>
and have your code appear to work.I would be nice to have something like
must_use
in Rust or the__attribute__((warn_unused_result))
in C or@warn_unused_result
in Swift.The text was updated successfully, but these errors were encountered: