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
Install defs from node_modules/<package>/flow-self-typed if it exists for each package #1435
base: master
Are you sure you want to change the base?
Install defs from node_modules/<package>/flow-self-typed if it exists for each package #1435
Conversation
Wow! I hadn't thought of this. My only concern is that it might get confusing using |
@mruzekw well, we would need to update the wiki to document this way of publishing types for a library if this PR gets merged. |
Yes, that sounds important. But I'm unclear on the differences now...could you clarify? The path and the directory tree in "Directory Structure" don't match. |
@mruzekw I meant that path to be within this repo, not within the package in question. I tweaked the wording: "A package's |
So the published package tree needs to have the following?
|
ah no, the published package needs to have
(as a sibling of Then when the package is installed there will be a |
Got it. Thanks for clarifying. It's unlikely a project would check these into git and just generate it as part of the build? |
@mruzekw yes, though if one needs to support multiple versions of flow, I don't think there's a very good way to autogenerate all the defs anyway... |
@mruzekw oh I think I misunderstood, you mean you would prefer to generate the The only problem is I don't think there's an automated way to generate these types of lib defs. Copying |
I have something in the works with respect to generating flow types across multiple versions. It's not easy... In the proof of concept stage. I mean you have to update all the flow types for every version with each change in package version anyway. Why not automate that? |
Oh, that's cool. Yeah by all means if you have a way to automate it, go for it! |
Cool, that seems like a separate choice from this PR anyway. Great work! Hope the maintainers and community will consider it. |
Oh! One more question. Can I test my package(d) types with different versions of flow? |
@mruzekw you mean using |
Oh wow, nice work! 💪 I'm gonna take some time to look over this change, and reach out to the others since this is a significant architectural change. @marudor Thoughts on this change? 💭 |
@gantoine do you think we should allow the |
I'm just a passer-by, but I have my doubts about the folder structure: if you're a library publisher that wants to publish flow types, then chances are you're already using If we now add our own type defs in there as well then we need to instruct our tools to treat half of the folder differently from the rest. Especially for include patterns this isn't very nice (such as the files array in Now this is all not impossible to do, but I think it would be more ergonomically to have a single folder dedicated to own types. This could either be a new top-level folder, or a single folder within |
That's a good point, I'm trying to think what other names would make sense for the own types folder... |
@gantoine what do you think about calling the types folder |
In all honesty I'm not too sure about this solution. At first glance I have to agree with the points Tiddo brought up, in that we can't hijack the At the very least I'll keep it open and we can keep discussing it, since it's an interesting idea to a real problem people are having. I'm sorry I can't be of more help, I just don't think I'm in a position to call the shots. 😞 |
I'm not sure if you fully understand the points that Tiddo brought up. Publishing I a package with its typedefs in a |
Oh no I understand what the purpose of My reservations are towards making such a change without input from the flow/flowtype team, or from library maintainers who have flow typedefs in their libraries. This would require changing the way people interact with flow and flow-typed, and I don't feel I'm in a position to make that call. |
I'm just happy this issue is getting some attention. I wish the flow team
were more proactive on this.
…On Nov 2, 2017 7:40 PM, "Georges-Antoine Assi" ***@***.***> wrote:
Oh no I understand what the purpose of flow-self-typed is, I wasn't
saying that his comments were why I was unsure of this change. From what I
can tell your solution would work just fine in the wild.
My reservations are towards making such a change without input from the
flow/flowtype team, or from library maintainers who have flow typedefs in
their libraries. This would require changing the way people interact with
flow and flow-typed, and I don't feel I'm in a position to make that call.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1435 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGn6kT3ArUDuM3lDriXKDpJU4CKUGgAks5symEPgaJpZM4QNTOY>
.
|
To be perfectly clear, here is how it would work with what I'm proposing that avoids the problem Tiddo mentioned. Let's say you're developing a package
Then someone installs
Now they run Does that clarify things? |
Also to be clear, we wouldn't have to make any changes to |
Not as far as I can tell. 😕 |
I really like the proposed solution, and I'd prefer adding more flexibility into Regarding,
I feel the same, but can empathize with a package author who does want to maintain multiple versions of their types. To satisfy both, this could look for specific flow version directories first and then look for libdefs in the That way, it's harder to get blocked. If package authors don't want to maintain more than one version of libdef, they don't have to. If someone needs to add backward compatibility, they can.
|
FWIW, I'm using the script written by @a-tokyo for now: facebook/flow#4323 |
@chrisgervang That's a good idea. I wish types from the |
@gantoine I didn't notice, looks like you guys have decided you'd like to adopt this approach in 3.0? If so I'll update the code to use the Also I may need help designing/figuring out an approach for running tests in |
Also @gantoine make sure no one mistakenly thinks this is ready and merges it -- it still uses the |
…ists for each package This is a workaround for facebook/flow#4917. **Note**: self-provided defs will only be found for packages that are already installed in `node_modules`! It also enables package authors to update their type defs without having to make PRs to `flow-typed`. If an installed package provides its own `flow-typed` directory it will override anything in `flow-typed`'s central repo. ### Directory structure A package's `flow-typed` directory has the same structure as `flow-typed/definitions/npm/<package>_v<version>/` would, except that the `.js` files must use the exact version of the package: ``` node_modules/underscore/ flow-typed/ flow_v0.13.x-v0.37.x/ underscore_v1.8.3.js flow_v0.38.x-/ underscore_v1.8.3.js ```
@gantoine are you able to run the chrome node inspector on Jest? I'm seeing errors like "Unable to open devtools socket: address already in use." |
301c031
to
c1b7c1a
Compare
@jedwards1211 I've never been able to use the debugger successfully, I usually resort to |
@gantoine it was painful but I finally solved my issues with Notes:
|
This is a workaround for facebook/flow#4917. (Problem: It's impossible to provide different
.js.flow
files for different versions of flow in the same package.)One can currently rely on PRing def updates for the various targeted flow versions to the central
flow-typed
repository instead of using.js.flow
files, but this has downsides:That's why I made this PR: this makes it possible to store definitions (which can target multiple versions of flow) in a
flow-self-typed
directory in the published package instead of making PRs to the central repo.Notes
node_modules
!flow-self-typed
directory it will override anything inflow-typed
's central repo.Directory structure
To use this feature, include a
flow-self-typed
directory in the root of a published package.Tue
flow-self-typed
directory must have the same structure asdefinitions/npm/<package>_v<version>/
in this repo would,except that the
.js
files must use the exact version of the package: