Is it necessary to explicitly set the variable type in TypeScript when it is inferred correctly? For example:
const add = (a: number, b: number) => a + b;
const result = add(2, 3);
// Or should I explicitly declare the return value type?
const add = (a: number, b: number): number => a + b;
const result = add(2, 3);
I understand that type inference covers many scenarios. If not considered bad practice, are there any instances where explicit types are preferred?