-
Notifications
You must be signed in to change notification settings - Fork 9
Flow: Return type annotations not supported on arrow functions #29
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
Comments
The more the better! The bugs are out there, and I can't fix them if I don't know about them. Unfortunately, this is another case where perfect parsing is impossible. The current syntax uses an imperfect lookahead to detect arrow functions. We can (and should) modify that lookahead to account for type annotations. However, since type annotations can involve arbitrarily complex expressions, it won't be perfect. I might not get to this for a few days, as I'll be travelling. |
I've just released version 1.0.18, which handles simple return type declarations. |
Is this in effect (1.0.19)? I'm assuming "simple return types" refer to, for example, primitives. // Syntax highlighting OK
value = () => {
// Do stuff
return this._input.value;
}
// Syntax highlighting not OK
value = (): string => {
// Do stuff
return this._input.value;
} |
It works for me. Try rebuilding your syntaxes.
Yes, single identifiers in general. |
Might be a bit of an edge-case, but the return type declarations seem to break string templates with substitutions for some reason (class context): export default class Foo {
// Highlighting OK
bar = (you: string = 'World') => {
return `Hello ${you}! ${'Welcome!'}`;
}
// Highlighting broken beyond this
baz = (you: string = 'World'): string => {
return `Hello ${you}! ${'Welcome!'}`;
}
} |
It's misparsing |
Should be fully working by now. |
As an aside, sorry for the issue spam over the last few days. I'm really liking this package so far.
The text was updated successfully, but these errors were encountered: