When I was writing type declarations of OOUI I found out that some OOUI classes are designed in violation of Liskov substitution principle, which is forbidden in TypeScript:
- OO.ui.mixin.GroupElement (Changes method signatures of OO.EmitterList)
- OO.ui.CheckboxInputWidget (Change signatures of change event)
- OO.ui.NumberInputWidget (Changes method signatures of OO.ui.TextInputWidget)
- OO.ui.OutlineControlsWidget (Change signatures of move and remove event)
- OO.ui.SelectFileWidget (Change signatures of change event and method signatures of SelectFileInputWidget)
- OO.ui.SelectWidget (Change signatures of move and remove event)
This makes TypeScript adoption difficult, as we have to write things like this:
// Error: Type 'NumberInputWidget' is not assignable to type 'TextInputWidget'... let widget: OO.ui.TextInputWidget = new OO.ui.NumberInputWidget(); // Use type assertion as a fix let widget: OO.ui.TextInputWidget = new OO.ui.NumberInputWidget() as unknown as OO.ui.TextInputWidget;
See also: T107639