-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Static Typing with Flow #8
Conversation
I found this lodash Flow interface: https://github.com/marudor/flowInterfaces/blob/master/packages/iflow-lodash/index.js.flow. I think it would be good to incorporate it in this PR to see how it goes. |
"lint": "eslint ." | ||
"lint": "eslint .", | ||
"flow": "flow; test $? -eq 0 -o $? -eq 2", | ||
"watch": "babel --watch=./src --out-dir=./lib" |
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.
What do we need watch
for?
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.
@stubailo I added it as a helper so you can live typecheck as you work. With flow being in the babelrc, on compile it typechecks. I can remove it though!
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.
Oh, interesting! I don't have anything against it, just thought it wouldn't do anything since I thought you needed to explicitly npm run flow
.
I assume there are also IDE/editor integrations that will run the typechecking for you in the editor, like you get with linting? That would be what I really want.
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.
Yeah both atom and VSCode have typechecking in the editor for flow
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.
I’ve just tried Flow integration in VSCode but I wasn’t able to make it work. The extension is developed by the Flow core team at Facebook, which is a good sign, but untouched for the past 4 months which is a bit sad.
One thing that was a bit sad was discovering that ImmutableJS only has TypeScript bindings and not Flow. I hope that doesn't make it much harder to integrate it later if we want to. |
@stubailo Generally speaking Typescript’s DefinitelyTyped is way more complete than Flow equivalents, however in the case of Immutable I was able to find this flow interface: https://github.com/marudor/flowInterfaces/blob/master/packages/iflow-immutable/index.js.flow (haven’t tried it). Also it seems that there is an effort at FlowTyped to provide something like DefinitelyTyped for flow. |
@@ -1,4 +1,6 @@ | |||
function stripLoc(obj) { | |||
// == `debug.js` == // |
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.
I cannot for the life of me figure out why these comments are here (in general, I'm tearing my hair out trying to get Flow and Nuclide to work together). What are they for? They seem to actually break Flow because it seems to expect the @flow
comment to be at the top of the file.
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.
@stubailo I can't remember now either. I think maybe the linter in atom added them? I had type errors with flow for normal types and I'm pretty sure I had them working with GraphQL types. I haven't tried nuclide yet though.
I'll get it back running locally and debug! Sorry about that!
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.
@stubailo I was pulling from the graphql source to get the type definitions since they aren't included in the distro. The easy way around this until they include it is to do a flow type def just like we have for typescript. Shouldn't take me long to implement 👍 so we can fully evaluate them both.
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.
Ohhh, that would explain why there were no errors.
Closing in favor of typescript |
This PR brings in support for static typing via flow. Currently it adds typing to the src files but not the test files.
It also adds flow to part of the post test scripts
I'll be doing the same thing with typescript so we can compare the two implemenations