-
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
more documentation #615
Comments
Since you're
If you're playing around, I would suggest relative imports, i.e. On (3), don't forget about intersections. I've had some success with intersecting classes against objects to impose: (1) is an instance of the class and (2) satisfies the structural constraints of the object. (In my use case, |
@samwgoldman Thanks for the help. I recently managed to use type imports and exports at work. Though most of them were named imports, I can try On (3) I've personally not used too many class types in practice. Instead I define all classes as objects instead. So I will do some more research on that as well. In regards to that, could you be so kind to also tell me something particular about declarations? Let's say, I have a commonJS project that happens to have a global variable called OT. To say something like. This object is of type T but with these additions (modifications)? Thanks for the help though. I'll make a PR with some documentation soon. |
See #396 for the non-answer to your |
I just read some more documentation, and it turns out that what I really want is Classes, and extends. |
About intersections, I did some research and an intersection between a class and an object works either way. Though it is a little strange to actually use in practice. It ends up making a smaller object. A union seems to be the correct tool for what you were describing. |
No, I mentioned the 'extends from' and 'implements' constraint. As long as your |
@popham I'm probably still confused about how intersections works exactly. I'll keep reading. |
In #679 I ran into a limitation in Flow. It turns out it's been covered elsewhere in: #282 Another common issue I run into is with decorator functions on React Classes:
exporting X asks you for annotations. Then these annotations help flow catch errors across module boundaries. However doing this instead erases all those errors:
Now flow has no idea what the type of the export is, and any type benefits across module boundaries are lost. The workaround to fix this problem is simple as well:
So my question is, is it a good idea put a collection of these common workarounds in the documentation. Some of them may not be needed in the near future. |
The heap refinement thing should absolutely be documented. Maybe someone will get really clever and limit the scope of the refinement havoc, but I don't think it'll happen any time soon, and when it does we can update the docs. The second issue you identified might be a bug. You mentioned it in #520 (comment) but I think it's worth opening an issue, because it's separate from autocomplete. I don't think anyone has really looked into the behavior you saw, so I wouldn't document that yet. |
I spent a bit of time improving (hopefully) the documentation around dynamic type tests and refinements. I added a "caveats" section that describes the scenarios in which flow will throw away a refinement. Hopefully we can use that to stem the tide of issues related to that behavior. Ref #711. |
Closing per @samwgoldman's docs improvements |
The documentation for flow hasn't been updated much in a long time, and the project itself has moved quite a bit. I think it would be great to have a section explaining these parts in more detail —
var x : (number) => string
import type x from 'y'
I'd be more than willing to create pull request if you can help me figure out 2.
(short answers here, or links will do) :)
The text was updated successfully, but these errors were encountered: