[React-Router-DOM] Fix exporting types for JetBrains IDE (#19856)

* Fix exporting types for JetBrains IDE

Rider always suggest me to use require instead of import because it didn't detect the imported type in the code.
Since this definitions use the declare module and the react-router definitions don't.

* Fix testing for trailing whitespace
This commit is contained in:
bergi9
2017-09-25 16:11:35 -07:00
committed by Mohamed Hegazy
parent fcc0e2ef35
commit 8d952056e7
+17 -41
View File
@@ -5,8 +5,11 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
declare module 'react-router-dom' {
import {
import { match } from "react-router";
import * as React from 'react';
import * as H from 'history';
export {
Prompt,
MemoryRouter,
Redirect,
@@ -20,61 +23,34 @@ declare module 'react-router-dom' {
matchPath,
withRouter,
RouterChildContext
} from 'react-router';
import * as React from 'react';
import * as H from 'history';
} from 'react-router';
interface BrowserRouterProps {
export interface BrowserRouterProps {
basename?: string;
getUserConfirmation?(): void;
forceRefresh?: boolean;
keyLength?: number;
}
class BrowserRouter extends React.Component<BrowserRouterProps> {}
}
export class BrowserRouter extends React.Component<BrowserRouterProps> {}
interface HashRouterProps {
export interface HashRouterProps {
basename?: string;
getUserConfirmation?(): void;
hashType?: 'slash' | 'noslash' | 'hashbang';
}
class HashRouter extends React.Component<HashRouterProps> {}
}
export class HashRouter extends React.Component<HashRouterProps> {}
interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
export interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
to: H.LocationDescriptor;
replace?: boolean;
}
class Link extends React.Component<LinkProps> {}
}
export class Link extends React.Component<LinkProps> {}
interface NavLinkProps extends LinkProps {
export interface NavLinkProps extends LinkProps {
activeClassName?: string;
activeStyle?: React.CSSProperties;
exact?: boolean;
strict?: boolean;
isActive?<P>(match: match<P>, location: H.Location): boolean;
}
class NavLink extends React.Component<NavLinkProps> {}
export {
BrowserRouter,
BrowserRouterProps, // TypeScript specific, not from React Router itself
HashRouter,
HashRouterProps, // TypeScript specific, not from React Router itself
LinkProps, // TypeScript specific, not from React Router itself
NavLinkProps, // TypeScript specific, not from React Router itself
Link,
NavLink,
Prompt,
MemoryRouter,
Redirect,
RouteComponentProps, // TypeScript specific, not from React Router itself
RouteProps, // TypeScript specific, not from React Router itself
Route,
Router,
StaticRouter,
Switch,
match, // TypeScript specific, not from React Router itself
matchPath,
withRouter,
RouterChildContext
};
}
export class NavLink extends React.Component<NavLinkProps> {}