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

gen-flow-files generates incorrect declaration for default function #2830

Closed
Gozala opened this issue Nov 16, 2016 · 2 comments
Closed

gen-flow-files generates incorrect declaration for default function #2830

Gozala opened this issue Nov 16, 2016 · 2 comments

Comments

@Gozala
Copy link
Contributor

Gozala commented Nov 16, 2016

Here is an example code:

/* @flow */

export const inc = (a:number):number =>
  a + 1

export default inc

gen-flow-files generates following typedefs:

// @flow

declare export default function(a: number): number;
declare export function inc(a: number): number;

Which it then fails to parse:

3: declare export default function(a: number): number;
                                  ^ Unexpected token (
3: declare export default function(a: number): number;
                                   ^ Unexpected identifier
3: declare export default function(a: number): number;
                                    ^ Unexpected token :
@patriq
Copy link

patriq commented Feb 12, 2018

Fixed it using this in my package.json file:

"build:flow": "flow gen-flow-files src/index.js > lib/index.js.flow && npm run fix-flow-issue-2830",
"fix-flow-issue-2830": "replace-in-file \"/default function(\\(.*\\)):/\" \"default \\$1 =>\" lib/index.js.flow --isRegex"

This, after generating the gen-flow-files will replace the unnamed default functions with the workaround in dogma-io/nodely#7

@TrySound
Copy link
Contributor

TrySound commented Feb 9, 2019

gen-flow-files replacement is coming soon

@TrySound TrySound closed this as completed Feb 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants