|
|
|
|
|
by d357r0y3r
2616 days ago
|
|
It's best to leverage type inference if possible. I can point to entire TypeScript files that could be copied and pasted into a JavaScript file and work with no changes. At some point, yes, you have to use annotations to get the most of it. But, ultimately, I'd much rather trade the additional characters now for the alternative: insanity producing runtime errors in production later. |
|
FuncA() returns T1, inferred. FuncB() expects it to return T2. Is FuncB expecting the wrong thing? Or is FuncA returning something incorrect?
Always annotating the return types fixes this. That's one area that I think inference is always risky.