News for hackers. Stuff that matters.
Re:Node.js adds experimental support for TypeScript by afiori on Friday July 26, 2024 @03:45AM (#41076626)
The key factor is that typescript is not a language, it is a notation system for a completely independent language.

The purpose of typescript is usefully type as much javascript as possible, to do both this and have a sound type system it would require to change javascript.

Re:Node.js adds experimental support for TypeScript by price on Friday July 26, 2024 @04:09AM (#41076755)
Definitely to get the most ergonomic programming experience, while also having a sound type system, you'd need to change some of the semantics of the language.

A prime example is that if you index into an array of type `T[]`, JS semantics mean the value you get back could be undefined as well as a `T`. So to describe existing JS semantics in a sound type system, the type would have to be `T | undefined`, which would be a big pain. Alternatively you could make the type `T`, but only if you make the runtime semantics be that an out-of-bounds access throws instead of returning undefined.