【发布时间】:2019-07-27 00:51:49
【问题描述】:
我在 React 中有以下 HOC:
`restricted` prop
const ConditionalSwitch = ({component: Component, showIfTrue, ...rest}) => (
showIfTrue
? <Component {...rest}/>
: null
);
如何定义 props 以便 Typescript 满意?
{component: Component, showIfTrue, ...rest}
我试过了
export interface CSProps {
component: any,
showIfTrue: boolean
}
这里如何处理...rest?
【问题讨论】:
-
我不确定我是否遵循,如果您想在 typescript 中表示您的组件不需要具有您可以使用的所有属性
Partials
标签: reactjs typescript