4 ms·
The only problem I can see is mixing strings and numbers. But there are probably more errors someone pro types would say is type errors while someone pro dynami
by z3t4 8y ago
The only problem I can see is mixing strings and numbers. But there are probably more errors someone pro types would say is type errors while someone pro dynamic/loose typing would say is not ... Here's a nasty bug that took me like two hours to debug (this is only two lines, but imagine a sea of code where such thing could easily hide). Can you spot it ?
var foo = [];
foo.push["bar"];
You could say it's a type error. It's however not caught by neither TypeScript or Flow.
- sonnyblarney 8y agoIf you want to type an array, you can do that in Typescript. let x:number[] = []; x.push("x"); Here, the transpiler will catch the error of trying to push a string to a number array. Typing is your friend, and it will in almost all cases help you write cleaner and safer code.