I use typescript 2.1 along with JSX and I try to use Partial mapped type for extend interface of react component with optional properties from interface with required properties.
this is interface with required properties:
interface ActionsCreators {
A: string;
B: string;
};
this is interface which I want to extend:
interface Props extends React.Props<any> {
C: string;
};
this is mapped type:
type ActionsCreatorsPartial = Partial<ActionsCreators>;
which give this result:
type ActionsCreatorsPartial = {
A?: string;
B?: string;
}
this is what I try to do:
interface Props extends React.Props<any>, ActionsCreatorsPartial {
C: string;
};
but I see compilation error: "an interface may only extend a class or another interface" How can I connect interface Props with ActionsCreatorsPartial type?
type Props = React.Props<any> & ActionsCreatorsPartial & { C: string; };- David Sherret