Given a component that has a props type of any, when wrapping the component in the withRouter HOC, the returned component has a prop type of {}. I would expect the return component to have a prop type of any.
any should not be narrowed to {}.
Components with any type are common when gradually migrating a codebase to TypeScript, where many components may have their prop types undefined whilst the codebase is gradually migrated.
Example:
import React, { SFC } from 'react';
import { withRouter } from 'react-router-dom';
const MyComponent: SFC<any> = () => null;
const MyComponentWithRouter = withRouter(MyComponent);
<MyComponentWithRouter
// Unexpected error: Property 'foo' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<any, never>, ComponentState>> & Rea...'.
foo={1}
/>
Related gcanti/typelevel-ts#19
This issue was introduced by the change in #21329 /cc @Grmiade (PR author)
If you know how to fix the issue, make a pull request instead.
If you do not mention the authors the issue will be ignored.
Given a component that has a props type of
any, when wrapping the component in thewithRouterHOC, the returned component has a prop type of{}. I would expect the return component to have a prop type ofany.anyshould not be narrowed to{}.Components with
anytype are common when gradually migrating a codebase to TypeScript, where many components may have their prop types undefined whilst the codebase is gradually migrated.Example:
Related gcanti/typelevel-ts#19
This issue was introduced by the change in #21329 /cc @Grmiade (PR author)
If you know how to fix the issue, make a pull request instead.
@types/react-routerpackage and had problems.Definitions by:inindex.d.ts) so they can respond.If you do not mention the authors the issue will be ignored.