Hacker News new | ask | show | jobs
by srcreigh 1709 days ago
TIL, interfaces can extend classes in TypeScript. [0] If interfaces could not extend classes, that would be a reason to use type programming.

Another reason could be a generic interface. If you have a lifecycle where a type is mutable at one point but immutable at later points, you could use mapped types to enforce those constraints on the class methods generically.

[0]: https://www.typescriptlang.org/play?#code/MYGwhgzhAEAKCmAnCB...