Re:Don't use functions as callbacks unless they're designed ...
by MaxBarraclough on Saturday February 06, 2021 @06:15AM
(#26045799)
Not including TypeScript.
[ Parent
| on HN ]
Re:Don't use functions as callbacks unless they're designed ...
by xsmasher on Saturday February 06, 2021 @09:03PM
(#26051962)
Just to clarify, if you update toReadableNumber to take a second parameter and that parameter is not a number, typescript will complain.*
TypeScript won't catch the original landmine because it ignores the extra parameters; maybe some linter would? Is there a rule that enforces "functions used by map must spell out all the parameters?"
* Example of typescript giving an error on toReadableNumber_v2: https://www.typescriptlang.org/play?#code/FAYw9gdgzgLgBAQwE5...