2 ms·
Sure, but that would require every subtype to override every method of the base type with a narrower return type, and do nothing except delegate to the base typ
by Arnavion 11y ago
Sure, but that would require every subtype to override every method of the base type with a narrower return type, and do nothing except delegate to the base type in the body. It would be tedious boilerplate.
Since the base type's implementation already returns `this`, it makes sense to be able to annotate the method as returning `this` and get the benefit automatically.
- deleted 11y ago[deleted]
- TazeTSchnitzel 11y agoAh, yes, that's a problem. In PHP, there's been some debate as to whether or not to support `static` (similar in function to TypeScript's `this`) as a return type, and that's one of the arguments in favour.