From 8d952056e7a2d8e1fe91a281d1aeae881de86cb2 Mon Sep 17 00:00:00 2001 From: bergi9 Date: Tue, 26 Sep 2017 01:11:35 +0200 Subject: [PATCH] [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 --- types/react-router-dom/index.d.ts | 58 +++++++++---------------------- 1 file changed, 17 insertions(+), 41 deletions(-) diff --git a/types/react-router-dom/index.d.ts b/types/react-router-dom/index.d.ts index a70613fa81..c9555834a9 100644 --- a/types/react-router-dom/index.d.ts +++ b/types/react-router-dom/index.d.ts @@ -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 {} +} +export class BrowserRouter extends React.Component {} - interface HashRouterProps { +export interface HashRouterProps { basename?: string; getUserConfirmation?(): void; hashType?: 'slash' | 'noslash' | 'hashbang'; - } - class HashRouter extends React.Component {} +} +export class HashRouter extends React.Component {} - interface LinkProps extends React.AnchorHTMLAttributes { +export interface LinkProps extends React.AnchorHTMLAttributes { to: H.LocationDescriptor; replace?: boolean; - } - class Link extends React.Component {} +} +export class Link extends React.Component {} - interface NavLinkProps extends LinkProps { +export interface NavLinkProps extends LinkProps { activeClassName?: string; activeStyle?: React.CSSProperties; exact?: boolean; strict?: boolean; isActive?

(match: match

, location: H.Location): boolean; - } - class NavLink extends React.Component {} - - 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 {}