Skip to content
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

grammar support for flowtype is missing #26

Closed
vith opened this issue Jul 18, 2015 · 12 comments
Closed

grammar support for flowtype is missing #26

vith opened this issue Jul 18, 2015 · 12 comments

Comments

@vith
Copy link
Contributor

vith commented Jul 18, 2015

I've got a very small start towards this in this branch that only supports type annotations in argument lists. Return type annotations break things:

screenshot from 2015-07-18 03 08 47

Should the return types be added to the end patterns of all the varieties of function literals or is there a better way to accomplish that without so much repetition?

@gandm
Copy link
Owner

gandm commented Jul 20, 2015

On holiday at the moment. I will review this when back.

@nmn
Copy link

nmn commented Jul 24, 2015

+1

@gandm
Copy link
Owner

gandm commented Jul 27, 2015

I've just committed a grammar change ( but not published) that I think gives you flowtype on functions/fat arrows. No support for let/const/var as this need thinking about. Let me know if it creates problems?

@gandm
Copy link
Owner

gandm commented Jul 27, 2015

Strike that!! I seemed to have regressed!

@nmn
Copy link

nmn commented Jul 27, 2015

should I not update to latest version then??

@gandm
Copy link
Owner

gandm commented Jul 27, 2015

Yes try it - When I just tested it again I was using someone else's grammar - Doh!! Now I've set it to mine it seems OK.

Don't forget the published version is still the old one. You will have to pull the one from github.

@nmn
Copy link

nmn commented Jul 27, 2015

hmm.. Ok let me try

@nmn
Copy link

nmn commented Jul 27, 2015

Hey, use this file for flow-tests: https://gist.github.com/kastermester/ad79da3e48064effd82e
That with the React source code is probably the best test possible.

(i'm still trying on my own code-base, will report back shortly)

@nmn
Copy link

nmn commented Jul 27, 2015

Ok, so I just tried it and it's not fixed. The colour has changed though.

I don't know how grammars work, but here's the problem:

(array: Array<V>): IndexedIterable<V>;

That is a valid declaration for flow. However language-babel interprets that as JSX and everything after the first <V> becomes one colour. (kind of like the colour of text in a JSX block).
Putting this comment at the end of the line seems to fix the problem:

// </> </>

(one closing tag for each angular bracket used in the line)
Which re-inforces my guess that it is being interpreted as JSX.

@gandm
Copy link
Owner

gandm commented Jul 27, 2015

Yeah it's definitely showing as JSX. Thanks for the flow test file above. I think this is going to be pretty difficult with the current grammar. I thought that templates may be an issue. Leave it with me.

@nmn
Copy link

nmn commented Jul 27, 2015

Thanks!

@gandm
Copy link
Owner

gandm commented Aug 9, 2015

@nmn, @vith - Just rolled out 0.11.0 with support for flowtype. See #39 and #40 for known problems.

Let me know if you have any issues.

@gandm gandm added the released label Aug 9, 2015
@gandm gandm closed this as completed Aug 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants