4 ms·
I have not found this to be the case in Typescript code I've worked on. The main issue I've found with TS is stuff coming in from outside the system as JSON tha
by cageface 5y ago
I have not found this to be the case in Typescript code I've worked on. The main issue I've found with TS is stuff coming in from outside the system as JSON that doesn't conform to expected formats.
- CryZe 5y agoOne issue I've noticed is that indexing into a T[] array where T can't be undefined, results in the expression to be of type T, not T | undefined, despite an out of bounds index evaluating to undefined. I believe I've seen that they recently added a setting that changes this though.
- cageface 5y agoA lot of statically typed languages leave array indexing as a loophole for convenience but yeah this can also be a source of errors.
- andy_ppp 5y agoConsider using https://github.com/gcanti/io-ts https://github.com/gcanti/io-ts to help with that...
- jakelazaroff 5y agoYou can solve the JSON issue by validating that it deserializes to a known type at the point of ingress. I wrote a small library that I use in basically every project to help with that: https://www.npmjs.com/package/narrows https://www.npmjs.com/package/narrows