Example:
/* @flow */
type Props = {
title: string;
age: number;
};
type WrapProps = $Diff<Props, {
age: number;
}>;
const Person = (props: Props) => {};
const YoungPerson = (props: WrapProps) => {
return Person({age: 21, ...props});
};
Gives an error:
14: return Person({age: 21, ...props});
^ object literal. Expected object instead of
14: return Person({age: 21, ...props});
^ Props
However if i declare WrapProps sub type manually, it works:
/* @flow */
type Props = {
title: string;
age: number;
};
/*type WrapProps = $Diff<Props, {
age: number;
}>;
*/
type WrapProps = {
title: string;
};
const Person = (props: Props) => {};
const YoungPerson = (props: WrapProps) => {
return Person({age: 21, ...props});
};
Seems like $Diff is not working correctly.
Example:
Gives an error:
However if i declare
WrapPropssub type manually, it works:Seems like $Diff is not working correctly.