mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00: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:
Vendored
+4
-1
@@ -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