首页 > 解决方案 > 转义 ESLint 在 React 打字稿函数中缺少函数的返回类型

问题描述

我有一个javascript函数,例如:

export default () => ({
  root: css`
    background-color: hotpink;
    margin-bottom: 1.45rem;
  `,
});

但是 ESLint 在这里抱怨?

Missing return type on function.eslint@typescript-eslint/explicit-module-boundary-types

或者一个功能性的 React 组件:

const Header: FC<Props> = ({ siteTitle }) => {

  return (
    <header>
        <h1>
           {siteTitle}
        </h1>
    </header>
  );
};

export default Header;

我喜欢编写我的功能组件,例如:

const Header = ({ siteTitle }: Props) => {

  return (
    <header>
        <h1>
           {siteTitle}
        </h1>
    </header>
  );
};

export default Header;

但后来我也得到:Missing return type on function.eslint@typescript-eslint/explicit-module-boundary-types

我需要做什么?

标签: reactjstypescripteslint

解决方案


@typescript-eslint/explicit-module-boundary-types": "off",


推荐阅读