Answers for "typescript missing return type on function"

1

typescript missing return type on function

//                    param type    return type
function myFunction(params: string): number {
  // do some with params (type string)
  // Return a number
}
// Leaving return type out may cause below error:
// Missing return type on function.eslint(@typescript-eslint/explicit-function-return-type)

// Example with React
import React from "react"; // or import React, { FC } from "react";
const Component: React.FC<MyPropType> = (props: MyPropType) => {
  return <p>Hello, React</p>;
}
Posted by: Guest on September-28-2021

Code answers related to "typescript missing return type on function"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language