【发布时间】: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
我该怎么办?
【问题讨论】:
-
键入函数的返回值。 (或者禁用规则,因为我更喜欢 - 让 TS 隐式推断事情在绝大多数时间 IMO 中都很好)
标签: reactjs typescript eslint