Material-ui 的 CardActionArea 组件 属性 的 Typescript 错误

Typescript error for Material-ui's CardActionArea component property

Material-ui Buttons | Third party routing library 文档指出我们需要使适配器将 react-router-dom/Link 组件封装到按钮中。但是对 CardActionArea (根据文档,这是一个 BaseButton)做同样的事情会给出以下 Typescript 错误:

main.tsx:24:10 - error TS2322: Type '{ children: Element; component: ForwardRefExoticComponent<LinkProps & RefAttributes<HTMLAnchorElement>>; to: string; }' is not assignable to type 'IntrinsicAttributes & CardActionAreaProps & { children?: ReactNode; }'.
  Property 'component' does not exist on type 'IntrinsicAttributes & CardActionAreaProps & { children?: ReactNode; }'.

14         <CardActionArea component={AdapterLink} to="/foo">
            ~~~~~~~~~~~~~~

代码仍然有效。这是一个显示第 14 行错误消息的最小示例:

注意:第6行有错误,因为Codesandbox在TypeScript文件中是运行 eslint,所以忽略它。

https://codesandbox.io/s/heuristic-bash-w17bu

这对我有用,我在 TypeScript 中没有错误:

<CardActionArea {...{ component: Link, to }}>