我找到了一种使其工作的方法:通过使用hoc
提供的type
参数调用 ,如下所示:
import ChildComponent, { Props as ChildComponentProps } from './child';
const WrappedChildComponent = hoc<ChildComponentProps>()(ChildComponent);
但我不是很喜欢。它要求我导出孩子的道具 (我宁愿不这样做),我 有种感觉,我正在告诉TypeScript 它应该能够推断出的东西。