-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
unnecessary-optional-chain incorrectly reports warning #8065
Comments
FYI flow.org/try can be configured for flowlint using flowlint comments: |
related: #8491 |
I think we got optional chaining and nullish coalescing to not do anymore hacks with fallback to empty object. You can return null instead and avoid unsealed object. |
@TrySound, this: const {a, b, c, d, e, f, g} = getSmth() ?? {}
return {a, b, c, d, e, f, g} still looks better to me than that: const smth = getSmth()
return {
a: smth?.a,
b: smth?.b,
c: smth?.c,
d: smth?.d,
e: smth?.e,
f: smth?.f,
g: smth?.g,
} My main usecase for this is |
@lukeapage looks like I found a workaround: const getBase = (state: State): $Rest<Base, {}> => ({...state.base}); |
Flow version: 0.107.0
Expected behavior
No warnings
Actual behavior
Cannot try on flow.org/try as it does not allow configuration of lint rules.
gives the following warning:
so if I try to fix it by adding explicit types, I get a new warning
gives
and if I try a third possibility I get another existing bug
gives
this 3rd example is: #2977
this issue is possibly the same underlying bug as in #6613 except that its pretty normal to use the null coalescing operator with optional chaining.
The text was updated successfully, but these errors were encountered: