profile
viewpoint

Ask questionsSuggestion: Add $FlowIgnore to the standardized suppression comments

<!-- Please fill out this entire template so that we can evaluate your proposal as quickly as possible. -->

I'm writing this as a sort of preliminary issue, as the feature that this suggestion is about hasn't been released yet, but I happened to notice commit 99fa5bf37c5630b44d134df0f1e5e0b6cb0ffe16 that will apparently remove the custom suppress comments–feature.

Proposal

I suggest that $FlowIgnore is added to the list of possible suppressors.

<!-- Explain why you need this change and why this cannot be addressed with Flow's current set of features. -->

Use case

$FlowIgnore is already used a lot in the wild. While refactoring a codebase away from it would probably be easy regex replace job, it's still a lot of changed lines in a large number of repositories.

Also, in my opinion, $FlowIgnore carries a semantic meaning that is different from the other mentioned suppressors ($FlowFixMe, $FlowIssue or $FlowExpectedError). To me, $FlowIgnore implies that the next line does something that Flow can't know to be correct, nor is it supposed to know (so it's not a "FlowIssue"), but the next line is clear enough for the programmer to reason about and verify for correctness, so it's not necessarily something to be fixed either. The most common example of these for me have been down-casts and casts from exact type to another exact type that is a subset of the first, where I would very explicitly write something like

const _dog: Animal = animal
// $FlowIgnore We know this is a Dog because its type was checked earlier.
const dog: Dog = _dog

Edit: A lot of the code shearch hits for FlowIgnore seem to come from the same dependency, maybe this search result is better: grep.app.

facebook/flow

Answer questions dsainati1

I'd happily accept a PR adding this feature.

useful!

Related questions

Common spread pattern leads to "exponentially large number of cases" errors hot 1
Flow issue "Please upgrade flow to version >=0.75." hot 1
Object.fromEntries type defs missing hot 1
Cannot set defaultProps with React.memo and React.forwardRef hot 1
Inexact rest object claims it may have properties it can't possibly have hot 1
Inexact rest object claims it may have properties it can't possibly have hot 1
Inexact rest object claims it may have properties it can't possibly have hot 1
0.92.0 release crashes on startup (Unix.Unix_error) hot 1
module.name_mapper does not find nested modules on windows hot 1
Cannot import useState because there is no useState export in react. hot 1
Can't use a default value from a destructuring assignment as a computed property since 0.111 hot 1
Support optional chaining - flow hot 1
Flow issue "Please upgrade flow to version >=0.75." hot 1
Allow explicitly including a folder under an ignored path hot 1
Flow caches and fails to purge errors hot 1
source:https://uonfu.com/
Github User Rank List