diff --git a/types/react-sizes/index.d.ts b/types/react-sizes/index.d.ts index bf5575281d558f..0e1c01292c5471 100644 --- a/types/react-sizes/index.d.ts +++ b/types/react-sizes/index.d.ts @@ -5,6 +5,6 @@ export interface Sizes { export function WithSizes<SP extends object, P extends SP>( mapSizesToProps: (sizes: Sizes) => SP, -): (component: React.ComponentType<P>) => React.ComponentType<P>; +): (component: React.ComponentType<P>) => React.ComponentType<Omit<P, keyof SP>>; export default WithSizes; diff --git a/types/react-sizes/react-sizes-tests.tsx b/types/react-sizes/react-sizes-tests.tsx index 89e33d099e9e66..38846809769843 100644 --- a/types/react-sizes/react-sizes-tests.tsx +++ b/types/react-sizes/react-sizes-tests.tsx @@ -7,8 +7,7 @@ interface TestProps { height: number; } -const mapSizesToProps = ({ width, height }: Sizes): TestProps => ({ - foo: "foo", +const mapSizesToProps = ({ width, height }: Sizes) => ({ width, height, }); @@ -26,4 +25,4 @@ const TestComponent: React.ComponentType<TestProps> = ({ foo, width, height }) = ); }; -WithSizes(mapSizesToProps)(TestComponent); // $ExpectType ComponentType<TestProps> +WithSizes<ReturnType<typeof mapSizesToProps>, TestProps>(mapSizesToProps)(TestComponent); // $ExpectType ComponentType<Omit<TestProps, "width" | "height">>