3 ms·
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 co
by srcreigh 5y 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/MYGwhgzhAEAKCmAnCB7AdtA3gKGn6aYAtvAFzQQAuiAlmgOYDcu+w6ViArsJSogBSES5DnXoBKLC3z5KACxoQAdEPjQAvAWLxmMgL7YD2OpSQAzMMDWwwieGkrR4AD1NoAJjATJ0UmcAUQdzs0cm9UNABtAF1mIzY0KgowEBAATzDbe0dNHH9A4PtySMxVcgByACkUeHK9aMMgA https://www.typescriptlang.org/play?#code/MYGwhgzhAEAKCmAnCB...