3 ms·
I haven’t personally benchmarked it, but I know it’s available as an eslint rule (all exported functions must have declared return types).
by travisd 5y ago
I 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.