Missing return type on function - in react (typescript) code
Missing accessibility modifier on method definition render.eslint(@typescript-eslint/explicit-member-accessibility)
Accessibility modifiers are things like public/private/protected. For render, this should be public.
So add the word public to render():
class Main extends Component { public render() { ... }}Missing return type on function.eslint(@typescript-eslint/explicit-function-return-type)
You shouldn't have that error here. This is telling you to add a return type to render, but since you've extended React.Component it should be able to load the type from the type definitions.
Have you added @types/react & @types/react-dom to your project?
If not, npm i -D @types/react @types/react-dom
Also looks like you need @types/redux
for your redux code: (npm i -D @types/redux
) import { Dispatch } from 'redux';
const mapDispatchToProps = (dispatch: Dispatch<any>) => { return { onNumberUp: () => dispatch({ type: 'NUMBER_UP' }), onNumberDown: () => dispatch({ type: 'NUMBER_DOWN' }), };};
Final note - I'm not a fan of the public/private accessor rule in ESLint. I would just disable it. More info here (point 1): https://medium.com/@martin_hotell/10-typescript-pro-tips-patterns-with-or-without-react-5799488d6680