In my App.tsx i got this:
- Missing return type on function.eslint(@typescript-eslint/explicit-function-return-type)
And in my main class component i got these:
- Missing accessibility modifier on method definition render.eslint(@typescript-eslint/explicit-member-accessibility)
- Missing return type on function.eslint(@typescript-eslint/explicit-function-return-type)
I'm using React with TypeScript. For linter I use ESLint and for code formating Prettier.
I found this info: https://github.com/typescript-eslint/typescript-eslint/blob/v1.6.0/packages/eslint-plugin/docs/rules/explicit-function-return-type.md , but I don't know how and where to apply it.
App.tsc
class Main extends Component {
render() {
return (
<Router>
<div>
<Link to="/">Home</Link>
<br />
<Link to="/component1">Component1</Link>
<br />
<Link to="/component2">Component2</Link>
<Route exact path="/" render={() => <h1>Home Page</h1>} />
<Route path="/component1" component={Component1} />
<Route path="/component2" component={Component2} />
</div>
</Router>
);
}
}
Component1.tsc
interface Props {
number: number;
onNumberUp: any;
onNumberDown: any;
}
const Component1 = (props: Props): JSX.Element => {
return (
<div>
<h1>Component1 content</h1>
<p>Number: {props.number}</p>
<button onClick={props.onNumberDown}>-</button>
<button onClick={props.onNumberUp}>+</button>
</div>
);
};
const mapStateToProps = (state: any) => {
return {
number: state.firstReducer.number,
};
};
const mapDispachToProps = (dispach: any) => {
return {
onNumberUp: () => dispach({ type: 'NUMBER_UP' }),
onNumberDown: () => dispach({ type: 'NUMBER_DOWN' }),
};
};
Reducer and actions are in separeate folders.
Component1 and Component2 are simillar.
Does someone knows how to fix this error?