-
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
Fix [declarations] not suppressing errors correctly & rename to [silence] #8105
Conversation
Personally I would have loved to see two separate PRs, one with the fix, and one with the rename. I don't want to see the fix blocked because of the time it will take to decide if the team wants to rename the feature or not... (considered it took months to finally ship |
I go both ways on that. I see wanting to ship the feature asap, but |
I get your point, but fixing the existing feature doesn't need much discussions around, it's a merge and ship. Renaming could potentially take years if we take in consideration similar PRs in the history of this project. So I'd be grateful to be able to use this feature with a inaccurate name, rather than not being able to use it at all. |
Let's see how they respond. This is why I contained the rename to the last
commit.
|
I sure hope not. The team expressed a new commitment toward the community in https://medium.com/flow-type/what-the-flow-team-has-been-up-to-54239c62004f, let's see how that manifests. |
/cc @gabelevi |
Thanks for this! The fix looks good to me. Beyond builtins, this should also fix it in cycles, which was broken because we check cycles in the "leader's" context, which might not be in I pretty firmly disagree with renaming it back to I think we should merge the first 2 commits (again, they look great) and can continue the naming debate in an issue. |
@mroch Could you please consider importing it without the last commit? This would be a great DX improvement. Thanks! :) |
@mroch Thanks for responding - I am more interested in getting this merged than in spending time bikeshedding the name. I am focused on the DX of using Flow, which is why this feature should exist in the first place. To be fair, the name is part of putting Flow users first and addressing their needs (i.e. "this file I don't own is throwing errors, I would like to silence them"). But they will get used to whatever feature is put in front of them, if it is genuinely useful. I will remove the last commit from this PR so it can be merged wholesale. |
Fixes facebook#6631, facebook#6717, facebook#7803. There are two major flaws in the original approach: 1. Silencing errors at the merge site does not work for builtins, as those errors are computed later, and 2. Putting that suppression in an if/else where the else block parsed comment error suppressions can cause [declarations] to actually create *more* errors, which was misleading a lot of people and masked the source of bugs. We now suppress entire files in error collation, at the very end of the error reporting process.
Related to the previous commit, this backs out some of the code in facebook#4916 related to file error suppression in the merge phase. This has the benefit of fixing erroneous ignoring of comment suppressions within those files, which was causing unexpected consequences.
a2e11e1
to
91ee689
Compare
Last commit is removed, merge conflict fixed, assuming build goes green we are clear for landing. |
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.
@mroch is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
here we go! since this PR is going to get closed and be hard to find, I'd love to continue the naming discussion in an issue.
that's a pretty good point. i think |
Overview
In #4916, @LegNeato wrote a feature to block reporting of errors in files matching regex patterns as
[silence]
in.flowconfig
. This sat for about 9 months as an open PR despite strong public support. Just before merging, this was renamed to[declarations]
.Why do we need it? As you can read in #4916's comments, and as I wrote in #4916 (comment), nearly every Flow version introduces breaking changes. A library written for a given Flow version is unlikely to work with any other version. This is especially true of very complex libraries like
react-native
that seem to break on a monthly basis.Unfortunately, by default, Flow reports errors internal to a module, even if these internal errors don't affect any user code. This means that, if a library uses a new feature that is not in the user's current version of Flow, or uses a feature that has been changes (like object types moving to exact-by-default), internal errors will abound. These errors make it difficult to distinguish actual user type errors, and make it impossible to rely on the
flow
binary's exit code for CI.The current alternatives are
[ignore]
, which causes import errors, and[untyped]
, which casts toany
.[declarations]
has the crucial distinction of leaving exported typedefs intact while ignoring internal errors, making it much easier to keep typedefs active while your project and its dependencies ebb and flow across many Flow versions.Unfortunately, #4916 did not actually implement
[silence]
correctly, and doubly unfortunate was the naming pushed through in the final hour. This PR fixes the implementation. Additionally, it renames[declarations]
back to[silence]
. This was not taken lightly but has been done due to the overwhelming majority of feedback preferring[silence]
and the confusion surrounding[declarations]
as it relates to "declaration files" (i.e..js.flow
files) and "type declarations" generally. This becomes even more confusing when comparing to other.flowconfig
directives such as[include]
.What Was Wrong
There are two major flaws in the original approach:
Context.remove_all_errors cx
) does not work for builtins,as those errors are computed later, and
parsed comment error suppressions can cause
[declarations]
toactually create more errors, which was misleading a lot of people
and masked the source of bugs in this feature.
Commits
Fixes #6631, #6717, #7803.
27fa53f is the first commit, which fixes
[declarations]
as written.We now suppress entire files in error collation, at the very end
of the error reporting process.
The second commit is a0aa29e.
This backs out some of the code
in #4916 related to file error suppression in the merge phase.
This has the benefit of fixing erroneous ignoring of comment
suppressions within those files, which was causing unexpected
consequences as listed in 2) above.
The last commit is a2e11e1.
We rename
[declarations]
to[silence]
This name has not gone over well: #6631 (comment)
and is confusing in multiple places, such as:
https://github.com/facebook/flow/blob/dd93de0a3796897fe07cca8a3bdc621c992a9880/website/en/docs/declarations/index.md
and
flow/tests/lib_interfaces/.flowconfig
Lines 5 to 6 in dd93de0
It is difficult to grep for, difficult to distinguish versus type declarations,
and is widely used interchangeably with "interfaces".
For these reasons and many more, it is best to rename this option now that it
is usable.
Pinging @mroch and @mrkev who helped get the original version of this in.