mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-17 03:24:15 +08:00
react-router: Improve typing of withRouter (#15144)
* Improve typing of withRouter Hoist typings of static methods. * Fix declaration order * Add test case
This commit is contained in:
5
react-router/lib/withRouter.d.ts
vendored
5
react-router/lib/withRouter.d.ts
vendored
@@ -6,4 +6,7 @@ interface Options {
|
||||
|
||||
type ComponentConstructor<P> = ComponentClass<P> | StatelessComponent<P>;
|
||||
|
||||
export default function withRouter<P>(component: ComponentConstructor<P>, options?: Options): ComponentClass<P>;
|
||||
declare function withRouter<P, S>(component: ComponentConstructor<P> & S, options?: Options): ComponentClass<P> & S;
|
||||
declare function withRouter<P>(component: ComponentConstructor<P>, options?: Options): ComponentClass<P>;
|
||||
|
||||
export default withRouter;
|
||||
|
||||
@@ -81,6 +81,7 @@ interface DashboardProps {
|
||||
}
|
||||
|
||||
class Dashboard extends React.Component<DashboardProps, {}> {
|
||||
static staticMethodToBeHoisted(): void {}
|
||||
|
||||
navigate() {
|
||||
var router = this.props.router;
|
||||
@@ -102,6 +103,8 @@ class Dashboard extends React.Component<DashboardProps, {}> {
|
||||
|
||||
const DashboardWithRouter = withRouter(Dashboard);
|
||||
|
||||
DashboardWithRouter.staticMethodToBeHoisted();
|
||||
|
||||
class NotFound extends React.Component<{}, {}> {
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user