【问题标题】:Escaping ESLint Missing return type on function in React typescript function转义 ESLint 在 React 打字稿函数中缺少函数的返回类型
【发布时间】:2021-06-27 12:59:12
【问题描述】:

我有一个 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

我该怎么办?

【问题讨论】:

标签: reactjs typescript eslint


【解决方案1】:

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

【讨论】:

  • 你好。应避免仅使用代码的答案。请考虑添加一些解释。
猜你喜欢
  • 2019-07-15
  • 2021-07-05
  • 2020-10-12
  • 2019-09-26
  • 2022-01-12
  • 1970-01-01
  • 2015-08-10
  • 2021-11-19
  • 2020-05-09
相关资源
最近更新 更多