Cannot export `declare`d functions in flow
See original GitHub issueBug Report
- I would like to work on a fix!
Current behavior A clear and concise description of the behavior.
Input Code
declare function foo(): void;
export { foo };
Expected behavior
This should parse without an error.
Babel Configuration
repros just using preset flow
Environment
- Babel version(s): v7.11.1
Possible Solution
This should work fine as it’s no different to either of these working cases
declare export function bar(): void;
declare var bam: string;
export { bam };
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Declare default export among other exports #1806 - GitHub
I'm experimenting with using module.name_mapper to replace the file from which Flow gets type info for this module, and this seems to work....
Read more >javascript - why I can't export export a declared function in ES6?
It just doesn't flow well without braces. Share.
Read more >Solved: Flow goes lost while export/importing a solution b...
I m trying to export this solution and import it into Environment B. ... The flow wont be connected when i try and...
Read more >Creating Library Definitions | Flow
To declare a global function that should be accessible throughout your project, use the declare function syntax in a libdef file: flow-typed/myLibDef.js ...
Read more >export - JavaScript - MDN Web Docs
The export declaration is used to export values from a JavaScript module. ... also var, let export function functionName() { /* …
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m trying to fix this, and Flow’s scope handling of
declare function
s seems completely random:I get your reasoning - but:
declare function foo(): void; export { foo };
, then you should also ban the variable decl case:declare var bam: string; export { bam };
.declare export function foo(): void
allowed? By your reasoning it should be banned.I don’t think babel should be in the business of validating semantics this deeply