-
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
Replace /* @flow */ with entry in .flowconfig #284
Comments
Related: #154 |
+1 |
1 similar comment
+1 |
I agree that this is an issue. Today Flow works such that UX for existing projects is better than UX for new projects. This is clearly a false dichotomy. With a simple toggle it should be possible to inverse the system such that e.g. |
We've talked about this a bit in team meetings as well but haven't come up with solutions to all of the issues yet. One of the most glaring concerns is how to deal with things like npm libraries that come in with this config assumed set (but the holistic project not -- or vice versa). Managing nested .flowconfigs is one option, but will likely be a tricky thing to solve (For example: what if an outer .flowconfig says to ignore something that's inside the domain of an inner .flowconfig project? etc...).
One thing we did recently that should help with this is to make it a parse error for a file to have type syntax if it lacks a All in all, I think we need to be a little careful with the decision-making here (both with regard to how shared flow libraries can interact with each other so as to not hurt the ecosystem, but also with regard to how best it makes sense to use Flow in various workflows like starting-from-scratch vs partial-conversion of a project)...but it's clear that it's something that people want, so we're definitely open to talking this through. |
I haven't checked, but now that we have |
Hello, am I wrong or this is fixed already?
https://flowtype.org/docs/advanced-configuration.html#options Seems that this also includes big directories such as |
|
I like the idea. If changing the behavior of |
I really want this! It stinks to have that ugly I agree that there's some complexities with libraries. However, I think it makes sense to add the option without coming up with a plan for flow-checked libraries; since it would still be useful for application developers. Library writers could continue to use the comments or the Eventually, it seems like there'd have to be some sort of of recursive |
I agree this sucks for new projects. We should add
that forces flow checking on all files in |
It seems that using --all + |
I tried
|
As a workaround, we created an eslint rule to check and remind developers to write the Eslint has systems to apply this rule to specific files or folders. Hope this issue gets solved as I don't really care for this comment in our non-library source files. EDIT: |
@eirikurn Thanks very much for that! But yeah, it would be better if I could just include every file in my |
I created a POC that uses the AST to detect imports and follow them with Node.js |
@jeffmo with projects like this: https://github.com/davidtheclark/cosmiconfig a lot of the work is already done. I'm sure we can come up with a solution to how to cascade configs. Checking from entry should work well in standard JS module environments (i.e: ECMA modules) as modules are easy to follow. Right now flow fails because of conflicting flow versions in third party modules and this is a BIG problem. Entry based resolution will be a massive improvement to Flow performance and will prevent bloated projects with third party modules errors. Because of that I think this feature should be implemented ASAP. |
Is 5.7.3 promotes this feature? |
@iddan 0.57.3 and nope. But node_modules are checked only if there is an import in non-node_modules files. |
Can there be an option that focus-check will check all source files and only flow files from node_modules? |
This feature makes a lot of sense. Not too sure about the similarities involved, but would it not be reasonable to backwards engineer how typescript does this? They seem to already have this feature |
@TrySound The point is that using a comment (// @flow) in the begin of a file is not just "unelegant", but it brings different problems in big projects.
My use-case is easy: The solution "all=true" doesn't work, cause when you use it, you have to ignore "./node_modules/", otherwise Flow will find a lot of errors in all the dependencies. But if you ignore node_modules, then it doesn't find the "*.js.flow" files delivered with the private package. All other JS tools (babel, webpack, eslint) have a way to select the destinations in which they need to be used. |
@gabrielenosso To force having |
BTW, you don't have to |
@TrySound forcing developers to insert a comment at the begin of each file is not the same as having a configuration which includes the source files.
For big teams, or in my case, where developers are coming from other languages, it results extremely confusing. In my opinion, it's a game changer on the selection of the types tool. @apsavin I didn't know about the [declarations]. |
Please don't talk about elegancy, it's highly subjective term. My team lead at previous work said that short code is more elegant than readable. Well, I disagree that 60 lines of unreadable code are better than 100 lines of really simple code. |
@TrySound Sorry, elegant was probably not the right term. A comment at the top of the file is not the best way, imho, to explain that the file can contain type declarations in a language that doesn't have them. I have this problem cause I am driving my company into the JS world, and all developers here are used to completely different languages (from C++, to native mobile languages, to .NET). And I think having a configuration setting for that would be also a step to align to the other popular JS tools. Anyway, I understand that it's not a "real problem" (especially in the new version where [declarations] seems to be a workaround for my case), but it would be surely a game changer to let more people choose Flow as the JS types tool. Thank you for your time :) |
@mrkev what do you think about the topic? |
Hmmm, radom thoughts here: Addressing @gabrielenosso's comments:
If you really want to, you can configure your own extensions for flow too ¯_(ツ)_/¯.
I don't think it's as big of a deal, no one should go "crazy". And if a comment line on the top of the file does make a dev in your team go crazy, I doubt the
I wouldn't go as far as to say game-changer, but I suppose it'd fit some people's use cases nicely, yeah.
|
@mrkev First, thank you for your time :) I try to reply to some of your comments:
About your points in the list: I completely agree with you on all of them. |
Yup, it would be an interesting feature to support, but I that sentiment I outlined is why it's not a priority. For using custom extensions btw: https://flow.org/en/docs/config/options/#toc-module-file-ext-string |
I use following solution which work great:
So
As a result:
There are one disadvantage of described solution. I need to include all well-typed modules (in P.S. Do not try specifying more exact path for well-typed modules. For example, including |
@alexandersorokin yeah, I mentioned |
I still think it is an important feature to enable type checking in a whole folder/project by default. Despite reading this thread, I don't understand why it is not done. Especially since any RN project comes with a default .flowconfig where |
Hello all, I believe the existing mechanisms using, |
I disagree. I want flow to run as if I had
As far as I can discern from this issue, there's currently no way to achieve this, which blows my mind. It sounds so simple. Just add a config option to specify files that flow should treat as if they included
I don't understand what the problem is. |
I absolutely second your explanation @Hubro. In fact nothing has changed here since jeff's comment three years ago (which explains "what the problem is" and my comment two years ago (which had the same suggestion)... |
None of the problems he lays out applies to my proposed solution though, unless I'm missing something. Just add a setting that will sneak in |
@Hubro what's wrong with ignoring |
That is not equivalent to adding Quoting @gabrielenosso from higher up in the issue:
|
It's a workaround, but it works [ignore]
./node_modules
!./node_modules/immutable
[options]
all=true |
@goodmind A feature this basic should absolutely not require a workaround. |
@goodmind That's still nowhere near equivalent to adding |
Ok, makes sense. I just don't think adding new section makes sense, maybe |
Shouldn't a configuration like this work? [options]
all=true
[declarations]
<PROJECT_ROOT>/node_modules |
When introducing Flow to legacy code, it's nice to specify on a per-file basis what files Flow should analyze. Thus, we have the
/* @flow */
or/* @flow weak */
comments at the top of each file. Once Flow is widely used in a project, I imagine that this would become extremely tedious. Or worse, someone may accidentally fail to include the comment and then we'll have no protection on that file with no warning that we don't. I supposeflow check --all
exists for these cases, but that's an extremely inflexible solution.Couldn't all these cases (analyze a few files, most files, or all files from a project) be solved more simply by providing a way to specify a glob or regex in .flowconfig that determines what files to analyze? That's what I assumed the
[include]
option was for, but it looks like it still requires the files listed to include the/* @flow */
comment (so it's more for checking files in a folder outside the one where .flowconfig is located).The text was updated successfully, but these errors were encountered: