-
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
[declarations] not working as expected #7803
Comments
I had to add a line feed after |
The problem is still occuring. The line -feed did not help, it only went away temporarily but the problem has surfaced again. |
I can confirm |
@FezVrasta does it work on previous versions? |
wondering if it could be the same as #6717 |
No it's definitely a different issue. I didn't have time to test a previous version, I'll give it a shot tomorrow |
@mroch please try this repro out: git clone [email protected]:FezVrasta/flow-issue-repro-7803.git
cd flow-issue-repro-7803
yarn --frozen-lockfile
$(yarn bin)/flow You should see errors coming from [declarations]
<PROJECT_ROOT>/node_modules/.* I tried even with Flow 0.90.0 and 0.99.0 and I got the same issue. Most of the errors are because of #6717, but there are some where a
|
@mroch did you ever find time to take a look at my repro? |
This bug still affects Flow (version 0.108.0). Does anyone know of any workaround to suppress these errors while maintaining the |
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.
@mroch I just realized this issue is a dupe of #6717 as you suggested, I thought it was different because I didn't see I guess we can close it and focus on #6717 |
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.
…[silence] Summary: # 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 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 to `any`. `[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: 1. Silencing errors at the merge site (`Context.remove_all_errors cx`) 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 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 https://github.com/facebook/flow/blob/dd93de0a3796897fe07cca8a3bdc621c992a9880/tests/lib_interfaces/.flowconfig#L5-L6 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. Pull Request resolved: #8105 Differential Revision: D17776374 Pulled By: mroch fbshipit-source-id: 1d5670e60a6aa4f636a40b609c7e2def5a88c06c
|
Flow version:
"flow-bin": "^0.100.0",
Expected behavior
I have the following declarations tag in .flowconfig
[declarations]
./node_modules/.
./graphql-iso-date/.
I am expecting to see no flow type errors in the following file:
node_modules/graphql-iso-date/dist/time/index.js.flow
Actual behavior
Flow throws a lot of errors in that file, disregarding the declarations tag. I was unable to setup a repro on flow try because there appeared to be no way to setup a .flowconfig file.
The text was updated successfully, but these errors were encountered: