Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upflow type annotations #157
Comments
This comment has been minimized.
This comment has been minimized.
caspervonb
commented
Jun 14, 2015
|
Intended URL http://flowtype.org |
This comment has been minimized.
This comment has been minimized.
|
@caspervonb thx, fixed it. |
This comment has been minimized.
This comment has been minimized.
nmn
commented
Jun 22, 2015
|
+1 |
This comment has been minimized.
This comment has been minimized.
nmn
commented
Jun 22, 2015
|
@davidpfahler have you tried using Babel-eslint parser?? |
This comment has been minimized.
This comment has been minimized.
nmn
commented
Jun 25, 2015
|
I tried to make it work in Atom but it didn't work. It worked in Sublime Text. I think this had something to do with it not picking up the custom parser from the package.json. That said, there was still the problem of not having access to some of the types defined by flow like |
This comment has been minimized.
This comment has been minimized.
|
@nmn would you mind posting your package.json configuration and the global trick you referred to? |
This comment has been minimized.
This comment has been minimized.
nmn
commented
Jun 26, 2015
|
The package.json has this in it:
The global trick is the one mentioned in the Readme: standard doesn't know what any of the type names are. So for an annotation like ReactElement, I had to add this to the file
This got rid of the errors. That said, for large files, this could quickly get out of hand as there will be tons of type annotations with different keywords and you'll have to declare all of them. Standard doesn't understand the common types such as I noticed that I was using the capitalised versions, which are incorrect of course. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@davidpfahler We need to figure out what changes would be needed in Declaring all possible globals is out of the question, especially for framework-specific globals like It's interesting that Can you run |
feross
added
the
feature request
label
Jun 28, 2015
This comment has been minimized.
This comment has been minimized.
nmn
commented
Jun 28, 2015
|
@feross I've kind of got it working with babel-eslint. I would say the most important feature for flow/typescript support is to have some more config to list out globals. This would also help with web worker code, probably. Both flow and typescript come with a long list of types. so if you can just define them all in one place that should work. |
This comment has been minimized.
This comment has been minimized.
hzoo
commented
Jul 1, 2015
|
Yeah before babel-eslint was just ignoring the types. @feross Yeah it's difficult since flow has it's own defined globals that ESLint won't know about - unless eslint can add a flow env or something for all those globals or you specify everything yourself. The other solution would be for the user to import that type in every file Related: babel/babel-eslint#130 |
This comment has been minimized.
This comment has been minimized.
nmn
commented
Jul 1, 2015
|
@hzoo The number of globals introduced by Flow are not that many. When you're using just eslint, you can just add them in the config file. Mine looks like this:
If you set the environment to both browser and node, all the other globals are available anyway. |
This comment has been minimized.
This comment has been minimized.
|
{
"standard": {
"globals": [
"ReactComponent",
"ReactElement",
"SyntheticEvent",
"SyntheticClipboardEvent",
"SyntheticCompositionEvent",
"SyntheticInputEvent",
"SyntheticUIEvent",
"SyntheticFocusEvent",
"SyntheticKeyboardEvent",
"SyntheticMouseEvent",
"SyntheticDragEvent",
"SyntheticWheelEvent",
"SyntheticTouchEvent"
]
}
}I think this will work well enough for now :) |
davidpfahler commentedJun 14, 2015
As far as I can tell, flow type annotations are not supported. Would be an awesome feature.