-
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
Changes from all commits
b4130ea
10afb89
636682d
b2d6c3e
50f5c20
80661f4
a5ca9cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
"presets": [ | ||
"stage-0", | ||
"es2015" | ||
] | ||
], | ||
"plugins": ["transform-flow-strip-types"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[libs] | ||
interfaces/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
function stripLoc(obj) { | ||
// == `debug.js` == // | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Ohhh, that would explain why there were no errors. |
||
// @flow | ||
function stripLoc(obj: Object) { | ||
// For development only! | ||
const _ = require('lodash'); | ||
if (! _.isObject(obj)) { | ||
|
@@ -12,6 +14,6 @@ function stripLoc(obj) { | |
}); | ||
} | ||
|
||
export function printAST(fragAst) { // eslint-disable-line no-unused-vars | ||
export function printAST(fragAst: Object) { // eslint-disable-line no-unused-vars | ||
console.log(JSON.stringify(stripLoc(fragAst), null, 2)); // eslint-disable-line no-console | ||
} |
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.
https://github.com/flowtype/flow-for-vscode