3 ms·
>type validation library to assist with this example? We don't, thus "[TypeScript] didn't solve the biggest issue[s] we had with Javascript". Also just notice
by Zamicol 3y ago
>type validation library to assist with this example?
We don't, thus "[TypeScript] didn't solve the biggest issue[s] we had with Javascript".
Also just noticed that I used the singular "issue", I meant the plural "issues", as there are many.
If I had an option to use an alternative to JavaScript, I would in a heart beat. But it's not practical to not use Javascript
- hn_throwaway_99 3y agoI am honestly curious what issues you hit with JavaScript that you find difficult for developers to avoid. I do think JS has a lot of weirdness and pitfalls, but I feel like the things you are actually ever reasonably likely to hit are easy to enumerate and learn: 1. Understanding truthy/falsey 2. The difference between null and undefined (but this is an area where Typescript helps). 3. == vs ===, but this one feels pretty easy to avoid, e.g. just set up eslint to forbid == if so desired. 4. Understand the details of how JS treats 'this' in different contexts. I think this (pun intended) is probably the most important thing to understand. 5. The bizarreness that typeof null === 'object'. There are of course other issues, but I honestly feel like I rarely if ever hit them, and I've been coding in JS/Node for many years now. I mean everyone loves to point out some of the insane implicit casting rules of JS (e.g. the JSFuck language), but I don't ever hit those in my day-to-day. I just feel Typescript plus some strongly opinionated eslint rules take 99% of the "gotchas" out of JS.