TypeScript: Arrow function is not compatible with ordinary one
TypeScript Version: 2.4.1
Code
class Component {
render(): boolean {
return false;
}
}
class App extends Component {
render = () => false;
}
Expected behavior:
Compiles correctly.
Actual behavior:
The compiler reports an error:
test.ts(7,3): error TS2424: Class 'Component' defines instance member function 'render', but extended class 'App' defines it as instance member property.
I know this may be designed, a feature rather than a bug, but such behavior is quite weird.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 9
- Comments: 16 (10 by maintainers)
Can’t find the PR for this but it does appear to have been fixed.
@m93a Class properties and arrow functions are both TC39-controlled entities now; proposals about new syntax that combine the two belong on ES Discuss or other forums.