4 ms·
This is incorrect: TypeScript doesn't require annotating functions with return types, and can infer return types from function bodies. It doesn't infer argumen
by reissbaker 7y ago
This is incorrect: TypeScript doesn't require annotating functions with return types, and can infer return types from function bodies.
It doesn't infer argument types, but it does infer return types.
- anderskaseorg 7y agoYou’re right, I must have been misremembering from a bug where return type inference was failing. So yeah, TypeScript doesn’t but perhaps should infer assertion signatures where a return type is not specified. However, it would be bad if people who do want to specify the return type were unable to do so, so an `asserts` annotation syntax would still need to be available.