|
|
|
|
|
by Arnavion
3305 days ago
|
|
>But in your TS example, the code would execute. Incorrect. It's a type alias so it uses "type typeof" not "value typeof". It doesn't have the problem that the issue you linked to is about. https://www.typescriptlang.org/play/#src=function%20getOptio... Observe the JS output contains no `typeof` and that the type `Options` is considered to be the same as `{ num: number, str: string }` if you hover over it. |
|
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.