News for hackers. Stuff that matters.
Re:Porffor: A from-scratch ahead-of-time JS engine by oxidant on Tuesday July 30, 2024 @11:07PM (#41116101)
This narrowing is probably not the best. I'm not sure why the TS docs suggest this approach. You should really check the type of the key to be safer, though it's still not perfect.

   if (typeof animal.swim === 'function') {....}
Re:Porffor: A from-scratch ahead-of-time JS engine by saghm on Thursday August 01, 2024 @12:23AM (#41126137)
Compilers don't really have the option of just avoiding non-idiomatic code, though. If the goal is to compile TypeScript ahead of time, the only options are to allow it or to break compatibility, and breaking compatibility makes using ahead-of-time TypeScript instead of some native language that already exists much less compelling.