Skip to content

Commit

Permalink
router: fix typing of IRouteProps.component (#1505)
Browse files Browse the repository at this point in the history
* router: fix typing of `IRouteProps.component`

Fix `SFC` to explicitly accept `any` as same as `IComponentConstructor` .

* add: test for Route
  • Loading branch information
tkamenoko authored Feb 15, 2020
1 parent df7b1c7 commit 078b323
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions packages/inferno-router/__tests__/Route.typings.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { render } from 'inferno';
import { Route, Router } from 'inferno-router';
import createMemoryHistory from 'history/createMemoryHistory';

describe('<Route component>', () => {
const history = createMemoryHistory();
const node = document.createElement('div');

it('receives { history, location, match } props', () => {
type RouteProps = {
history: any;
location: any;
match: any;
};
let actual: RouteProps = {
history: null,
location: null,
match: null,
};
const Component = (props: RouteProps) => (actual = props) && null;

render(
<Router history={history}>
<Route path="/" component={Component} />
</Router>,
node
);

expect(actual.history).toBe(history);
expect(typeof actual.match).toBe('object');
expect(typeof actual.location).toBe('object');
});
});
2 changes: 1 addition & 1 deletion packages/inferno-router/src/Route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface IRouteProps {
exact?: boolean;
strict?: boolean;
sensitive?: boolean;
component?: IComponentConstructor<any> | SFC;
component?: IComponentConstructor<any> | SFC<any>;
render?: (props: RouteComponentProps<any>, context: any) => InfernoNode;
location?: H.Location;
children?: ((props: RouteComponentProps<any>) => InfernoNode) | InfernoNode;
Expand Down

0 comments on commit 078b323

Please sign in to comment.