News for hackers. Stuff that matters.
Re:Fast and precise type checking for JavaScript by styfle on Thursday November 09, 2017 @12:30PM (#15664181)
Agreed. This is one of the things people hate about type systems is fighting with them saying "I know better".

This example is quite interesting because javascript itself does not provide a way to check the type of an array, unlike a primitive. This is likely due to the fact that an empty array doesn't really have a type for it's items yet.

Here is an example where typescript can infer the type using the `typeof` runtime check but provide compile time checking.

https://www.typescriptlang.org/play/index.html#src=function%...

There are no comments on this comment yet.