L Liskov Substitution Principle LSP
3 sectionsRapid overview
Liskov Substitution Principle (LSP)
TL;DR
LSP says any implementation of an interface must be usable wherever the interface is expected, without surprises. Throwing "not supported" from a method you were forced to declare is the classic violation — it pushes type-shaped runtime bug…
Read →How it works
> "Derived classes/implementations should be substitutable for their base classes/interfaces."
Read →Quick recall Q&A
Q: How do you detect LSP violations in React/TypeScript? A: Watch for: - Implementations that throw errors for base interface methods - Type guards checking specific implementations before calling methods - Components that check instanceof …
Read →