score:24

Accepted answer

as explained by nicholas tower in this answer typescript | warning about missing return type of function, eslint, depending on the react version that you are using, you can use any of the lines below:

if you're on the latest react version (16.8.0 or later), do this: const component: react.functioncomponent<props> = (props: props) => { }

prior to 16.8, you'd instead do: const component: react.sfc<props> = (props: props) => {}

where sfc stands for "stateless functional component".

edit:------

based on @sergiop's comment, a more idiomatic solution would be

const test = ({ title }: props): jsx.element => <div>{title}</div>

score:3

i too faced this issue.

const handlelogout = () => {
router.push('/')
} 

the above code given same issue to me, then code is updated like below, then error disappear in my case

const handlelogout = (): void => {
router.push('/')
}

reference link: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md


Related Query

More Query from same tag