5 ms·
To this point, many teams are already using subsets of TypeScript to improve compilation times. Often times it’s things like always declaring return types on fu
by travisd 5y ago
To this point, many teams are already using subsets of TypeScript to improve compilation times. Often times it’s things like always declaring return types on functions to avoid the compiler having to infer it (especially between module boundaries). Calling this a “subset of typescript” might be strong wording, but it does suggest there is some desire in that general area.
- fault1 5y agoIt seems like depending on how you configure typescript (e.g, in tsconfig), typescript is already something like an ensemble of mini-languages with different dialects and semantics. Much more so than other languages. But I agree, restricted typescript that has to do less work (data or control flow analysis) would probably be on the orders of magnitude faster.
- vosper 5y ago> To this point, many teams are already using subsets of TypeScript to improve compilation times. Often times it’s things like always declaring return types on functions to avoid the compiler having to infer it (especially between module boundaries). I hadn't heard of this trick - how much improvement does it make? Seems like it might be good for readability, too?
- travisd 5y agoI haven’t personally benchmarked it, but I know it’s available as an eslint rule (all exported functions must have declared return types).
- afdbcreid 5y agoI always thought this is because some people prefer this style.
- Smaug123 5y agoThis makes sense for semantic reasons though. If you accidentally return a `number` when you returned a `string` in some earlier branch, Typescript will happily unify them and now your function silently returns `string | number`. The linting rule prevents this.
- rslabbert 5y agoI haven't found any large scale analyses but here's an example of a simple type annotation halving compilation time: https://stackoverflow.com/questions/36624273/investigating-long-typescript-compile-times https://stackoverflow.com/questions/36624273/investigating-l... The Typescript compiler performance wiki might also be of interest: https://github.com/microsoft/TypeScript/wiki/Performance https://github.com/microsoft/TypeScript/wiki/Performance