3 ms·
80/20 rule. The dumbest possible type inference algorithm... let x = value; // typeof(x) is now typeof(value) ... covers 80% of the cases where you'd lik
by alexvitkov 2y ago
80/20 rule.
The dumbest possible type inference algorithm...
let x = value; // typeof(x) is now typeof(value)
... covers 80% of the cases where you'd like type inference. I'd even argue it's way more than 80%.
Surprisingly, this is what C++ actually went for, and `auto` works just fine. Same in TypeScript - make a best effort guess from the value, fallback to `any` no value or type is given.
Having to write out a type every now and then costs me way less time than waiting for the compiler to finish playing minimax against itself in the latent space of all possible programs or whatever.