close

[Solved] Typescript Warning about Missing return type on function.eslint

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Typescript Warning about Missing return type on function.eslint in reactjs. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How To Solve Typescript Warning about Missing return type on function.eslint Error ?

  1. How To Solve Typescript Warning about Missing return type on function.eslint Error?

    To Solve Typescript Warning about Missing return type on function.eslint Error Just using the types provided by react; they'll include the return type. If you're on version 16.8.0 or later of react.

  2. Typescript Warning about Missing return type on function.eslint

    To Solve Typescript Warning about Missing return type on function.eslint Error Just using the types provided by react; they'll include the return type. If you're on version 16.8.0 or later of react.

Solution 1

Just using the types provided by react; they’ll include the return type. If you’re on version 16.8.0 or later of react, do this.

const Component: React.FunctionComponent<Props> = (props) => (

Or use the shorthand:

const Component: React.FC<Props> = (props) => (

Prior to 16.8, you’d instead do:

const Component: React.SFC<Props> = (props) => (

Where SFC stands for “stateless functional component”. They changed the name, since function components are no longer necessarily stateless.

Solution 2

For a function return type it goes after the arguments:

({ prop }: Props & T): JSX.Element => {}

JSX.Element is what TypeScript will infer, it’s a pretty safe bet.

If you’re curious, you should be able to see what TypeScript infers as the return type by hovering over Component, this will show the entire signature.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment