Typescript组合泛型对象类型

Typescript组合泛型对象类型,typescript,Typescript,我使用的是一个React模块,它的声明类型如下 export declare type SomeContainer = React.FunctionComponent<{ prop1: string prop2: number prop3: () => void }> 但问题是,当我将这种新类型用于我的功能组件时 const Component: Combined = props => { 我得到的错误参数'props'隐式地有一个'any',

我使用的是一个React模块,它的声明类型如下

export declare type SomeContainer = React.FunctionComponent<{
    prop1: string
    prop2: number
    prop3: () => void
}>
但问题是,当我将这种新类型用于我的功能组件时

const Component: Combined = props => {
我得到的错误
参数'props'隐式地有一个'any'
,并且所有属性都不能用于
props
变量


有没有一种方法可以组合这些类型以实现我想要的功能,或者我必须用自己的模块类型在内部声明模块类型?

您可以提取传递给
容器的参数的类型信息
函数:

type SomeContainerArgType = SomeContainer extends (arg1: infer U) => any ? U : any;
然后:

type MyType = SomeContainerArgType & {
    prop4: string;
};

type DesiredContainer = React.FunctionComponent<MyType>;
type MyType=SomeContainerArgType&{
prop4:字符串;
};
类型DesiredContainer=React.FunctionComponent;
const Component: Combined = props => {
type SomeContainerArgType = SomeContainer extends (arg1: infer U) => any ? U : any;
type MyType = SomeContainerArgType & {
    prop4: string;
};

type DesiredContainer = React.FunctionComponent<MyType>;