The following code is a completely valid module in Node.js:
return;
This is because of the function that wraps all Node modules:
(function (exports, require, module, __filename, __dirname) {
// code gets "injected" here
});
However, Flow hits a parse error and throws "Illegal return statement" for the file. Is there a way to avoid the parse error without wrapping the entire module in a pointless IIFE?
Somewhat related: #6351
What's your use case for this? Exposing that implementation detail at the type level seems like it adds complexity for little benefit.
Well, one example would be short-circuiting behavior in a script (e.g. processing command-line arguments) without prematurely exiting the process (a la process.exit()) so that other async events can finish.
How about this:
/*:: (function (exports, require, module, __filename, __dirname) { */
return;
/*:: })(); */
Actually yeah, that would solve it. Don't know why I hadn't thought of doing that, thanks @jcready :smile:
Most helpful comment
How about this: