iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
😖
I Created a Repository of Ways to Break Type Safety in TypeScript
Practical statically typed languages usually have backdoors for doing dangerous things[1], but TypeScript is unique in that these backdoors often exist in places that aren't obvious at first glance.
So, I've tried writing unsafe_cast<T, U>(x: T): U in various ways. Quite handy.
Acknowledgments: Many of these techniques are based on an article by Mr. tkr.
-
Scala's
asInstanceOf[T], Haskell'sunsafeCoerce, OCaml'sObj.magic, ... ↩︎
Discussion