4 ms·
I don't understand. In your transpiled code, getOptions is clearly being called in JS. In flow, getOptions() wouldn't be in the transpiled code at all. Imagin
by silviogutierrez 9y ago
I don't understand. In your transpiled code, getOptions is clearly being called in JS.
In flow, getOptions() wouldn't be in the transpiled code at all.
Imagine the body of getOptions as an extremely expensive computation. Some prime calculation. But you only want its return type. In flow comments, you can get it.
In the approach of your snippet, you could get it, but it will execute the full function with the full price.
- Arnavion 9y agoMy bad, I thought you were referring to `typeof` being the code that still executes. Now I read that tweet more carefully and noticed the `getOptions()` call is in a comment. A strange feature that I suppose is useful when dealing with complex anonymous types, though in my experience such complex types tend to be named.
- wereHamster 9y agoThe minifier would get rid of the __options__, and also the function getOptions because both are not used in the resulting code. You need a minifier in any serious project.
- silviogutierrez 9y agoIt wouldn't. getOptions() could have side effects that we want to run. Imagine inside of getOptions we have a prompt() call to fill in some of the options...