News for hackers. Stuff that matters.
Re:TypeScript support in Electron by silviogutierrez on Saturday June 03, 2017 @02:22AM (#14475264)
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.

Re:TypeScript support in Electron by Arnavion on Saturday June 03, 2017 @03:34AM (#14475423)
My 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.
Re:TypeScript support in Electron by wereHamster on Saturday June 03, 2017 @04:19AM (#14475508)
The 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.
Re:TypeScript support in Electron by silviogutierrez on Sunday June 04, 2017 @03:12AM (#14480249)
It 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...