Archiv für den Monat: Januar 2022

Why TypeScripts never type is super useful

At first glance, the never type  does not sound very useful for everyday coding. But actually, the following property of the type comes in very handy:

[…] The never type is assignable to every type; however, no type is assignable to never (except never itself) […]

With a small hack, this can be used to increase the type safety of a code base with no risk of breaking existing code and without any runtime overhead.

Weiterlesen