From 1fb801b4155cb95695504d36354ca2c801667bb6 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Tue, 14 Mar 2017 17:17:12 +0100 Subject: [PATCH 1/5] Update React Router to version 4.0 --- react-router-dom/index.d.ts | 80 ++++++++ react-router-dom/tsconfig.json | 18 ++ react-router-dom/tslint.json | 6 + react-router/examples/Ambiguous.tsx | 50 +++++ react-router/examples/Animation.tsx | 123 ++++++++++++ react-router/examples/Auth.tsx | 101 ++++++++++ react-router/examples/Basic.tsx | 73 ++++++++ react-router/examples/CustomLink.tsx | 45 +++++ react-router/examples/ModalGallery.tsx | 177 ++++++++++++++++++ react-router/examples/NoMatch.tsx | 48 +++++ react-router/examples/Params.tsx | 31 +++ .../examples/PreventingTransitions.tsx | 74 ++++++++ react-router/examples/README.md | 1 + react-router/examples/Recursive.tsx | 50 +++++ react-router/examples/RouteConfig.tsx | 88 +++++++++ react-router/examples/Sidebar.tsx | 80 ++++++++ react-router/index.d.ts | 154 +++++++++------ react-router/tsconfig.json | 70 +++---- react-router/tslint.json | 9 +- react-router/v3/index.d.ts | 62 ++++++ react-router/{ => v3}/lib/IndexLink.d.ts | 0 react-router/{ => v3}/lib/IndexRedirect.d.ts | 0 react-router/{ => v3}/lib/IndexRoute.d.ts | 0 react-router/{ => v3}/lib/Link.d.ts | 0 react-router/{ => v3}/lib/PatternUtils.d.ts | 0 react-router/{ => v3}/lib/PropTypes.d.ts | 0 react-router/{ => v3}/lib/Redirect.d.ts | 0 react-router/{ => v3}/lib/Route.d.ts | 0 react-router/{ => v3}/lib/RouteUtils.d.ts | 0 react-router/{ => v3}/lib/Router.d.ts | 0 react-router/{ => v3}/lib/RouterContext.d.ts | 0 .../{ => v3}/lib/applyRouterMiddleware.d.ts | 0 react-router/{ => v3}/lib/browserHistory.d.ts | 0 .../{ => v3}/lib/createMemoryHistory.d.ts | 0 react-router/{ => v3}/lib/hashHistory.d.ts | 0 react-router/{ => v3}/lib/match.d.ts | 0 .../{ => v3}/lib/useRouterHistory.d.ts | 0 react-router/{ => v3}/lib/withRouter.d.ts | 0 react-router/{ => v3}/react-router-tests.tsx | 0 react-router/v3/tsconfig.json | 46 +++++ react-router/v3/tslint.json | 1 + 41 files changed, 1288 insertions(+), 99 deletions(-) create mode 100644 react-router-dom/index.d.ts create mode 100644 react-router-dom/tsconfig.json create mode 100644 react-router-dom/tslint.json create mode 100644 react-router/examples/Ambiguous.tsx create mode 100644 react-router/examples/Animation.tsx create mode 100644 react-router/examples/Auth.tsx create mode 100644 react-router/examples/Basic.tsx create mode 100644 react-router/examples/CustomLink.tsx create mode 100644 react-router/examples/ModalGallery.tsx create mode 100644 react-router/examples/NoMatch.tsx create mode 100644 react-router/examples/Params.tsx create mode 100644 react-router/examples/PreventingTransitions.tsx create mode 100644 react-router/examples/README.md create mode 100644 react-router/examples/Recursive.tsx create mode 100644 react-router/examples/RouteConfig.tsx create mode 100644 react-router/examples/Sidebar.tsx create mode 100644 react-router/v3/index.d.ts rename react-router/{ => v3}/lib/IndexLink.d.ts (100%) rename react-router/{ => v3}/lib/IndexRedirect.d.ts (100%) rename react-router/{ => v3}/lib/IndexRoute.d.ts (100%) rename react-router/{ => v3}/lib/Link.d.ts (100%) rename react-router/{ => v3}/lib/PatternUtils.d.ts (100%) rename react-router/{ => v3}/lib/PropTypes.d.ts (100%) rename react-router/{ => v3}/lib/Redirect.d.ts (100%) rename react-router/{ => v3}/lib/Route.d.ts (100%) rename react-router/{ => v3}/lib/RouteUtils.d.ts (100%) rename react-router/{ => v3}/lib/Router.d.ts (100%) rename react-router/{ => v3}/lib/RouterContext.d.ts (100%) rename react-router/{ => v3}/lib/applyRouterMiddleware.d.ts (100%) rename react-router/{ => v3}/lib/browserHistory.d.ts (100%) rename react-router/{ => v3}/lib/createMemoryHistory.d.ts (100%) rename react-router/{ => v3}/lib/hashHistory.d.ts (100%) rename react-router/{ => v3}/lib/match.d.ts (100%) rename react-router/{ => v3}/lib/useRouterHistory.d.ts (100%) rename react-router/{ => v3}/lib/withRouter.d.ts (100%) rename react-router/{ => v3}/react-router-tests.tsx (100%) create mode 100644 react-router/v3/tsconfig.json create mode 100644 react-router/v3/tslint.json diff --git a/react-router-dom/index.d.ts b/react-router-dom/index.d.ts new file mode 100644 index 0000000000..7b827ba3d5 --- /dev/null +++ b/react-router-dom/index.d.ts @@ -0,0 +1,80 @@ +// Type definitions for React Router 4.0 +// Project: https://github.com/ReactTraining/react-router +// Definitions by: Tanguy Krotoff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'react-router-dom' { + import { + Prompt, + MemoryRouter, + Redirect, + RouteComponentProps, + PartialRouteComponentProps, + RouteProps, + Route, + Router, + StaticRouter, + Switch, + match, + matchPath, + withRouter + } from 'react-router'; + import * as React from 'react'; + import * as H from 'history'; + + + interface BrowserRouterProps { + basename?: string; + getUserConfirmation?: () => void; + forceRefresh?: boolean; + keyLength?: number; + } + class BrowserRouter extends React.Component {} + + + interface HashRouterProps { + basename?: string; + getUserConfirmation?: () => void; + hashType?: 'slash' | 'noslash' | 'hashbang'; + } + class HashRouter extends React.Component {} + + + interface LinkProps extends React.HTMLAttributes { + to: H.LocationDescriptor; + replace?: boolean; + } + class Link extends React.Component {} + + + interface NavLinkProps extends LinkProps { + activeClassName?: string; + activeStyle?: React.CSSProperties; + exact?: boolean; + strict?: boolean; + isActive?: (location: H.Location, props: any) => boolean; + } + class NavLink extends React.Component {} + + + export { + BrowserRouter, + HashRouter, + LinkProps, // TypeScript specific, not from React Router itself + Link, + NavLink, + Prompt, + MemoryRouter, + Redirect, + RouteComponentProps, // TypeScript specific, not from React Router itself + PartialRouteComponentProps, // 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 + } +} diff --git a/react-router-dom/tsconfig.json b/react-router-dom/tsconfig.json new file mode 100644 index 0000000000..41c143c1c6 --- /dev/null +++ b/react-router-dom/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "module": "commonjs", + "lib": ["es6", "dom"], + "jsx": "react", + "strictNullChecks": true, + "noImplicitAny": true, + "noImplicitThis": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/react-router-dom/tslint.json b/react-router-dom/tslint.json new file mode 100644 index 0000000000..cfdf2986e5 --- /dev/null +++ b/react-router-dom/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "../tslint.json", + "rules": { + "no-single-declare-module": false + } +} diff --git a/react-router/examples/Ambiguous.tsx b/react-router/examples/Ambiguous.tsx new file mode 100644 index 0000000000..971636a1e0 --- /dev/null +++ b/react-router/examples/Ambiguous.tsx @@ -0,0 +1,50 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + Route, + Link, + Switch +} from 'react-router-dom' + +const AmbiguousExample = () => ( + +
+
    +
  • About Us (static)
  • +
  • Company (static)
  • +
  • Kim (dynamic)
  • +
  • Chris (dynamic)
  • +
+ + {/* + Sometimes you want to have a whitelist of static paths + like "/about" and "/company" but also allow for dynamic + patterns like "/:user". The problem is that "/about" + is ambiguous and will match both "/about" and "/:user". + Most routers have an algorithm to decide for you what + it will match since they only allow you to match one + "route". React Router lets you match in multiple places + on purpose (sidebars, breadcrumbs, etc). So, when you + want to clear up any ambiguous matching, and not match + "/about" to "/:user", just wrap your s in a + . It will render the first one that matches. + */} + + + + + +
+
+) + +const About = () =>

About

+const Company = () =>

Company

+const User: React.SFC> = ({ match }) => ( +
+

User: {match.params.user}

+
+) + +export default AmbiguousExample \ No newline at end of file diff --git a/react-router/examples/Animation.tsx b/react-router/examples/Animation.tsx new file mode 100644 index 0000000000..1696dfd6fd --- /dev/null +++ b/react-router/examples/Animation.tsx @@ -0,0 +1,123 @@ +import * as React from 'react' +import * as ReactCSSTransitionGroup from 'react-addons-css-transition-group' +import { + BrowserRouter as Router, + RouteComponentProps, + Route, + LinkProps, + Link, + Redirect +} from 'react-router-dom' + +/* you'll need this CSS somewhere +.fade-enter { + opacity: 0; + z-index: 1; +} +.fade-enter.fade-enter-active { + opacity: 1; + transition: opacity 250ms ease-in; +} +*/ + +const AnimationExample = () => ( + + ( +
+ ( + + )}/> + +
    + Red + Green + Blue + Pink +
+ +
+ + {/* no different than other usage of + ReactCSSTransitionGroup, just make + sure to pass `location` to `Route` + so it can match the old location + as it animates out + */} + + +
+
+ )}/> +
+) + +const NavLink: React.SFC = (props) => ( +
  • + +
  • +) + +interface HSLParams { + h: number; + s: number; + l: number; +} + +const HSL: React.SFC> = ({ match: { params } }) => ( +
    hsl({params.h}, {params.s}%, {params.l}%)
    +) + +const styles: any = {} + +styles.fill = { + position: 'absolute', + left: 0, + right: 0, + top: 0, + bottom: 0 +} + +styles.content = { + ...styles.fill, + top: '40px', + textAlign: 'center' +} + +styles.nav = { + padding: 0, + margin: 0, + position: 'absolute', + top: 0, + height: '40px', + width: '100%', + display: 'flex' +} + +styles.navItem = { + textAlign: 'center', + flex: 1, + listStyleType: 'none', + padding: '10px' +} + +styles.hsl = { + ...styles.fill, + color: 'white', + paddingTop: '20px', + fontSize: '30px' +} + +export default AnimationExample \ No newline at end of file diff --git a/react-router/examples/Auth.tsx b/react-router/examples/Auth.tsx new file mode 100644 index 0000000000..86dffe2b63 --- /dev/null +++ b/react-router/examples/Auth.tsx @@ -0,0 +1,101 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + RouteProps, + Route, + Link, + Redirect, + withRouter +} from 'react-router-dom' + +//////////////////////////////////////////////////////////// +// 1. Click the public page +// 2. Click the protected page +// 3. Log in +// 4. Click the back button, note the URL each time + +const AuthExample = () => ( + +
    + +
      +
    • Public Page
    • +
    • Protected Page
    • +
    + + + +
    +
    +) + +const fakeAuth = { + isAuthenticated: false, + authenticate(this: any, cb: () => void) { + this.isAuthenticated = true + setTimeout(cb, 100) // fake async + }, + signout(this: any, cb: () => void) { + this.isAuthenticated = false + setTimeout(cb, 100) + } +} + +const AuthButton = withRouter(({ history }) => ( + fakeAuth.isAuthenticated ? ( +

    + Welcome! +

    + ) : ( +

    You are not logged in.

    + ) +)) + +const PrivateRoute: React.SFC = ({ component, ...rest }) => ( + ( + fakeAuth.isAuthenticated ? React.createElement(component! as React.SFC, props) : ( + + ) + )}/> +) + +const Public: React.SFC> = () =>

    Public

    +const Protected: React.SFC> = () =>

    Protected

    + +class Login extends React.Component, {redirectToReferrer: boolean}> { + state = { + redirectToReferrer: false + } + + login = () => { + fakeAuth.authenticate(() => { + this.setState({ redirectToReferrer: true }) + }) + } + + render() { + const { from } = this.props.location.state || { from: { pathname: '/' } } + const { redirectToReferrer } = this.state + + if (redirectToReferrer) { + return ( + + ) + } + + return ( +
    +

    You must log in to view the page at {from.pathname}

    + +
    + ) + } +} + +export default AuthExample \ No newline at end of file diff --git a/react-router/examples/Basic.tsx b/react-router/examples/Basic.tsx new file mode 100644 index 0000000000..16ff86947a --- /dev/null +++ b/react-router/examples/Basic.tsx @@ -0,0 +1,73 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + Route, + Link +} from 'react-router-dom' + +const BasicExample = () => ( + +
    +
      +
    • Home
    • +
    • About
    • +
    • Topics
    • +
    + +
    + + + + +
    +
    +) + +const Home = () => ( +
    +

    Home

    +
    +) + +const About = () => ( +
    +

    About

    +
    +) + +const Topics: React.SFC> = ({ match }) => ( +
    +

    Topics

    +
      +
    • + + Rendering with React + +
    • +
    • + + Components + +
    • +
    • + + Props v. State + +
    • +
    + + + ( +

    Please select a topic.

    + )}/> +
    +) + +const Topic: React.SFC> = ({ match }) => ( +
    +

    {match.params.topicId}

    +
    +) + +export default BasicExample \ No newline at end of file diff --git a/react-router/examples/CustomLink.tsx b/react-router/examples/CustomLink.tsx new file mode 100644 index 0000000000..2159cf039a --- /dev/null +++ b/react-router/examples/CustomLink.tsx @@ -0,0 +1,45 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + Route, + LinkProps, + Link +} from 'react-router-dom' + +const CustomLinkExample = () => ( + +
    + + +
    + + +
    +
    +) + +interface OldSchoolMenuLinkProps extends LinkProps { + activeOnlyWhenExact?: boolean; +} + +const OldSchoolMenuLink: React.SFC = ({ label, to, activeOnlyWhenExact }) => ( + ( +
    + {match ? '> ' : ''}{label} +
    + )}/> +) + +const Home = () => ( +
    +

    Home

    +
    +) + +const About = () => ( +
    +

    About

    +
    +) + +export default CustomLinkExample \ No newline at end of file diff --git a/react-router/examples/ModalGallery.tsx b/react-router/examples/ModalGallery.tsx new file mode 100644 index 0000000000..ccaefe3adc --- /dev/null +++ b/react-router/examples/ModalGallery.tsx @@ -0,0 +1,177 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + Switch, + RouteComponentProps, + Route, + Link +} from 'react-router-dom' + +// This example shows how to render two different screens +// (or the same screen in a different context) at the same url, +// depending on you got there. +// +// Click the colors and see them full screen, then "visit the +// gallery" and click on the colors. Note the URL and the component +// are the same as before but now we see them inside a modal +// on top of the old screen. + +class ModalSwitch extends React.Component, void> { + + // We can pass a location to that will tell it to + // ignore the router's current location and use the location + // prop instead. + // + // We can also use "location state" to tell the app the user + // wants to go to `/images/2` in a modal, rather than as the + // main page, keeping the gallery visible behind it. + // + // Normally, `/images/2` wouldn't match the gallery at `/`. + // So, to get both screens to render, we can save the old + // location and pass it to Switch, so it will think the location + // is still `/` even though its `/images/2`. + previousLocation = this.props.location + + componentWillUpdate(nextProps: RouteComponentProps) { + const { location } = this.props + // set previousLocation if props.location is not modal + if ( + nextProps.history.action !== 'POP' && + (!location.state || !location.state.modal) + ) { + this.previousLocation = this.props.location + } + } + + render() { + const { location } = this.props + const isModal = !!( + location.state && + location.state.modal && + this.previousLocation !== location // not initial render + ) + return ( +
    + + + + + + {isModal ? : null} +
    + ) + } +} + +const IMAGES = [ + { id: 0, title: 'Dark Orchid', color: 'DarkOrchid' }, + { id: 1, title: 'Lime Green', color: 'LimeGreen' }, + { id: 2, title: 'Tomato', color: 'Tomato' }, + { id: 3, title: 'Seven Ate Nine', color: '#789' }, + { id: 4, title: 'Crimson', color: 'Crimson' } +] + +const Thumbnail: React.SFC<{color: string}> = ({ color }) => +
    + +const Image: React.SFC<{color: string}> = ({ color }) => +
    + +const Home = () => ( +
    + Visit the Gallery +

    Featured Images

    +
      +
    • Tomato
    • +
    • Crimson
    • +
    +
    +) + +const Gallery = () => ( +
    + {IMAGES.map(i => ( + + +

    {i.title}

    + + ))} +
    +) + +const ImageView: React.SFC> = ({ match }) => { + const image = IMAGES[parseInt(match.params.id, 10)] + if (!image) { + return
    Image not found
    + } + + return ( +
    +

    {image.title}

    + +
    + ) +} + +const Modal: React.SFC> = ({ match, history }) => { + const image = IMAGES[parseInt(match.params.id, 10)] + if (!image) { + return null! + } + const back = (e: React.MouseEvent) => { + e.stopPropagation() + history.goBack() + } + return ( +
    +
    +

    {image.title}

    + + +
    +
    + ) +} + +const ModalGallery = () => ( + + + +) + +export default ModalGallery \ No newline at end of file diff --git a/react-router/examples/NoMatch.tsx b/react-router/examples/NoMatch.tsx new file mode 100644 index 0000000000..10b7a64fa9 --- /dev/null +++ b/react-router/examples/NoMatch.tsx @@ -0,0 +1,48 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + Route, + Link, + Switch, + Redirect +} from 'react-router-dom' + +const NoMatchExample = () => ( + +
    +
      +
    • Home
    • +
    • Old Match, to be redirected
    • +
    • Will Match
    • +
    • Will Not Match
    • +
    • Also Will Not Match
    • +
    + + + + + + +
    +
    +) + +const Home = () => ( +

    + A <Switch> renders the + first child <Route> that + matches. A <Route> with + no path always matches. +

    +) + +const WillMatch = () =>

    Matched!

    + +const NoMatch: React.SFC> = ({ location }) => ( +
    +

    No match for {location.pathname}

    +
    +) + +export default NoMatchExample \ No newline at end of file diff --git a/react-router/examples/Params.tsx b/react-router/examples/Params.tsx new file mode 100644 index 0000000000..148161c317 --- /dev/null +++ b/react-router/examples/Params.tsx @@ -0,0 +1,31 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + Route, + Link +} from 'react-router-dom' + +const ParamsExample = () => ( + +
    +

    Accounts

    +
      +
    • Netflix
    • +
    • Zillow Group
    • +
    • Yahoo
    • +
    • Modus Create
    • +
    + + +
    +
    +) + +const Child: React.SFC> = ({ match }) => ( +
    +

    ID: {match.params.id}

    +
    +) + +export default ParamsExample \ No newline at end of file diff --git a/react-router/examples/PreventingTransitions.tsx b/react-router/examples/PreventingTransitions.tsx new file mode 100644 index 0000000000..b23ba65608 --- /dev/null +++ b/react-router/examples/PreventingTransitions.tsx @@ -0,0 +1,74 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + Route, + Link, + Prompt +} from 'react-router-dom' + +const PreventingTransitionsExample = () => ( + +
    +
      +
    • Form
    • +
    • One
    • +
    • Two
    • +
    + +

    One

    }/> +

    Two

    }/> +
    +
    +) + +class Form extends React.Component { + state = { + isBlocking: false + } + + render() { + const { isBlocking } = this.state + + return ( +
    { + event.preventDefault(); + (event.target as HTMLFormElement).reset(); + this.setState({ + isBlocking: false + }) + }} + > + ( + `Are you sure you want to go to ${location.pathname}` + )} + /> + +

    + Blocking? {isBlocking ? 'Yes, click a link or the back button' : 'Nope'} +

    + +

    + { + this.setState({ + isBlocking: event.target.value.length > 0 + }) + }} + /> +

    + +

    + +

    + + ) + } +} + +export default PreventingTransitionsExample \ No newline at end of file diff --git a/react-router/examples/README.md b/react-router/examples/README.md new file mode 100644 index 0000000000..341bd29130 --- /dev/null +++ b/react-router/examples/README.md @@ -0,0 +1 @@ +Examples taken from https://github.com/ReactTraining/react-router/tree/22bd52c901ef0312348c2b02549c7102bd5653ae/packages/react-router-website/modules/examples diff --git a/react-router/examples/Recursive.tsx b/react-router/examples/Recursive.tsx new file mode 100644 index 0000000000..ec6e77207b --- /dev/null +++ b/react-router/examples/Recursive.tsx @@ -0,0 +1,50 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + Route, + Link, + match +} from 'react-router-dom' +import * as H from 'history'; + +const PEEPS = [ + { id: 0, name: 'Michelle', friends: [ 1, 2, 3 ] }, + { id: 1, name: 'Sean', friends: [ 0, 3 ] }, + { id: 2, name: 'Kim', friends: [ 0, 1, 3 ], }, + { id: 3, name: 'David', friends: [ 1, 2 ] } +] + +const find = (id: number) => PEEPS.find(p => p.id == id) + +const RecursiveExample = () => ( + + + +) + +interface PersonProps extends Partial> { + match: match<{id: number}>; +} + +const Person: React.SFC = ({ match }) => { + const person = find(match.params.id) + + return ( +
    +

    {person!.name}’s Friends

    +
      + {person!.friends.map(id => ( +
    • + + {find(id)!.name} + +
    • + ))} +
    + +
    + ) +} + +export default RecursiveExample \ No newline at end of file diff --git a/react-router/examples/RouteConfig.tsx b/react-router/examples/RouteConfig.tsx new file mode 100644 index 0000000000..1dffdc1527 --- /dev/null +++ b/react-router/examples/RouteConfig.tsx @@ -0,0 +1,88 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + RouteProps, + Route, + Link +} from 'react-router-dom' + +// Some folks find value in a centralized route config. +// A route config is just data. React is great at mapping +// data into components, and is a component. + +//////////////////////////////////////////////////////////// +// first our route components +const Main = () =>

    Main

    + +const Sandwiches = () =>

    Sandwiches

    + +interface PropsWithRoutes extends RouteComponentProps { + routes: Array; +} + +const Tacos: React.SFC = ({ routes }) => ( +
    +

    Tacos

    +
      +
    • Bus
    • +
    • Cart
    • +
    + + {routes.map((route, i) => ( + + ))} +
    +) + +const Bus = () =>

    Bus

    +const Cart = () =>

    Cart

    + +//////////////////////////////////////////////////////////// +// then our route config +interface MyRouteProps extends RouteProps { + component: React.SFC; + routes?: MyRouteProps[]; +} +const routes: Array = [ + { path: '/sandwiches', + component: Sandwiches + }, + { path: '/tacos', + component: Tacos, + routes: [ + { path: '/tacos/bus', + component: Bus + }, + { path: '/tacos/cart', + component: Cart + } + ] + } +] + +// wrap and use this everywhere instead, then when +// sub routes are added to any route it'll work +const RouteWithSubRoutes = (route: MyRouteProps) => ( + ( + // pass the sub-routes down to keep nesting + + )}/> +) + +const RouteConfigExample = () => ( + +
    +
      +
    • Tacos
    • +
    • Sandwiches
    • +
    + + {routes.map((route, i) => ( + + ))} +
    +
    +) + +export default RouteConfigExample \ No newline at end of file diff --git a/react-router/examples/Sidebar.tsx b/react-router/examples/Sidebar.tsx new file mode 100644 index 0000000000..fb81829dfb --- /dev/null +++ b/react-router/examples/Sidebar.tsx @@ -0,0 +1,80 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteProps, + Route, + Link +} from 'react-router-dom' + +// Each logical "route" has two components, one for +// the sidebar and one for the main area. We want to +// render both of them in different places when the +// path matches the current URL. +interface MyRoute extends RouteProps { + sidebar: () => JSX.Element; + main: () => JSX.Element; +} +const routes: Array = [ + { path: '/', + exact: true, + sidebar: () =>
    home!
    , + main: () =>

    Home

    + }, + { path: '/bubblegum', + sidebar: () =>
    bubblegum!
    , + main: () =>

    Bubblegum

    + }, + { path: '/shoelaces', + sidebar: () =>
    shoelaces!
    , + main: () =>

    Shoelaces

    + } +] + +const SidebarExample = () => ( + +
    +
    +
      +
    • Home
    • +
    • Bubblegum
    • +
    • Shoelaces
    • +
    + + {routes.map((route, index) => ( + // You can render a in as many places + // as you want in your app. It will render along + // with any other s that also match the URL. + // So, a sidebar or breadcrumbs or anything else + // that requires you to render multiple things + // in multiple places at the same URL is nothing + // more than multiple s. + + ))} +
    + +
    + {routes.map((route, index) => ( + // Render more s with the same paths as + // above, but different components this time. + + ))} +
    +
    +
    +) + +export default SidebarExample \ No newline at end of file diff --git a/react-router/index.d.ts b/react-router/index.d.ts index 05fe9b3371..1e0f01510c 100644 --- a/react-router/index.d.ts +++ b/react-router/index.d.ts @@ -1,62 +1,104 @@ -// Type definitions for react-router 3.0 -// Project: https://github.com/rackt/react-router -// Definitions by: Sergey Buturlakin -// Yuichi Murata -// Václav Ostrožlík -// Nathan Brown -// Alex Wendland -// Kostya Esmukov -// John Reilly -// Karol Janyst -// Dovydas Navickas +// Type definitions for React Router 4.0 +// Project: https://github.com/ReactTraining/react-router +// Definitions by: Sergey Buturlakin , Yuichi Murata , Václav Ostrožlík , Nathan Brown , Alex Wendland , Kostya Esmukov , Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 -export { - ChangeHook, - EnterHook, - InjectedRouter, - LeaveHook, - ParseQueryString, - RouteComponent, - RouteComponents, - RouteComponentProps, - RouteConfig, - RoutePattern, - RouterProps, - RouterState, - RedirectFunction, - StringifyQuery -} from "react-router/lib/Router"; -export { LinkProps } from "react-router/lib/Link"; -export { IndexLinkProps } from "react-router/lib/IndexLink"; -export { RouteProps, PlainRoute } from "react-router/lib/Route"; -export { IndexRouteProps } from "react-router/lib/IndexRoute"; -export { RedirectProps } from "react-router/lib/Redirect"; -export { IndexRedirectProps } from "react-router/lib/IndexRedirect"; +declare module 'react-router' { + import * as React from 'react'; + import * as H from 'history'; -/* components */ -export { default as Router } from "react-router/lib/Router"; -export { default as Link } from "react-router/lib/Link"; -export { default as IndexLink } from "react-router/lib/IndexLink"; -export { default as withRouter } from "react-router/lib/withRouter"; -/* components (configuration) */ -export { default as IndexRedirect } from "react-router/lib/IndexRedirect"; -export { default as IndexRoute } from "react-router/lib/IndexRoute"; -export { default as Redirect } from "react-router/lib/Redirect"; -export { default as Route } from "react-router/lib/Route"; + interface MemoryRouterProps { + initialEntries?: H.Location[]; + initialIndex?: number; + getUserConfirmation?: () => void; + keyLength?: number; + } + class MemoryRouter extends React.Component {} -/* utils */ -export { createRoutes } from "react-router/lib/RouteUtils"; -export { default as RouterContext } from "react-router/lib/RouterContext"; -export { routerShape, locationShape } from "react-router/lib/PropTypes"; -export { default as match } from "react-router/lib/match"; -export { default as useRouterHistory } from "react-router/lib/useRouterHistory"; -export { formatPattern } from "react-router/lib/PatternUtils"; -export { default as applyRouterMiddleware } from "react-router/lib/applyRouterMiddleware"; -/* histories */ -export { default as browserHistory } from "react-router/lib/browserHistory"; -export { default as hashHistory } from "react-router/lib/hashHistory"; -export { default as createMemoryHistory } from "react-router/lib/createMemoryHistory"; + interface PromptProps { + message: string | ((location: H.Location) => void); + when?: boolean; + } + class Prompt extends React.Component {} + + + interface RedirectProps { + to: H.LocationDescriptor; + push?: boolean; + from?: string; + } + class Redirect extends React.Component {} + + + interface RouteComponentProps

    { + match: match

    ; + location: H.Location; + history: H.History; + } + + interface PartialRouteComponentProps

    extends Partial> { + } + + interface RouteProps { + location?: H.Location; + component?: React.SFC | void> | React.ComponentClass | void>; + render?: (props: RouteComponentProps) => React.ReactNode; + children?: (props: RouteComponentProps) => React.ReactNode | React.ReactNode; + path?: string; + exact?: boolean; + strict?: boolean; + } + class Route extends React.Component {} + + + interface RouterProps { + history: any; + } + class Router extends React.Component {} + + + interface StaticRouterProps extends RouterProps { + basename?: string; + location?: string | object; + context?: object; + } + class StaticRouter extends React.Component {} + + + interface SwitchProps extends RouteProps { + } + class Switch extends React.Component {} + + + interface match

    { + params: P; + isExact?: boolean; + path?: string; + url?: string; + } + + + function matchPath

    (pathname: string, props: RouteProps): match

    ; + + + function withRouter(component: React.SFC> | React.ComponentClass>): React.ComponentClass; + + + export { + MemoryRouter, + Prompt, + Redirect, + RouteComponentProps, // TypeScript specific, not from React Router itself + PartialRouteComponentProps, // 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 + } +} diff --git a/react-router/tsconfig.json b/react-router/tsconfig.json index 301ed3f651..c7af9e3fcf 100644 --- a/react-router/tsconfig.json +++ b/react-router/tsconfig.json @@ -1,44 +1,30 @@ { - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "jsx": "react", - "baseUrl": "../", - "typeRoots": ["../"], - "paths": { - "history": ["history/v3"], - "history/*": ["history/v3/*"] - }, - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "lib/applyRouterMiddleware.d.ts", - "lib/browserHistory.d.ts", - "lib/createMemoryHistory.d.ts", - "lib/hashHistory.d.ts", - "lib/IndexLink.d.ts", - "lib/IndexRedirect.d.ts", - "lib/IndexRoute.d.ts", - "lib/Link.d.ts", - "lib/match.d.ts", - "lib/PatternUtils.d.ts", - "lib/PropTypes.d.ts", - "lib/Redirect.d.ts", - "lib/Route.d.ts", - "lib/Router.d.ts", - "lib/RouterContext.d.ts", - "lib/RouteUtils.d.ts", - "lib/useRouterHistory.d.ts", - "lib/withRouter.d.ts", - "react-router-tests.tsx" - ] + "compilerOptions": { + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "module": "commonjs", + "lib": ["es6", "dom"], + "jsx": "react", + "strictNullChecks": true, + "noImplicitAny": true, + "noImplicitThis": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true + }, + "files": [ + "index.d.ts", + "examples/Ambiguous.tsx", + "examples/Animation.tsx", + "examples/Auth.tsx", + "examples/Basic.tsx", + "examples/CustomLink.tsx", + "examples/ModalGallery.tsx", + "examples/NoMatch.tsx", + "examples/Params.tsx", + "examples/PreventingTransitions.tsx", + "examples/Recursive.tsx", + "examples/RouteConfig.tsx", + "examples/Sidebar.tsx" + ] } diff --git a/react-router/tslint.json b/react-router/tslint.json index 377cc837d4..0209984d72 100644 --- a/react-router/tslint.json +++ b/react-router/tslint.json @@ -1 +1,8 @@ -{ "extends": "../tslint.json" } +{ + "extends": "../tslint.json", + "rules": { + "no-empty-interface": false, + "void-return": false, + "no-single-declare-module": false + } +} diff --git a/react-router/v3/index.d.ts b/react-router/v3/index.d.ts new file mode 100644 index 0000000000..05fe9b3371 --- /dev/null +++ b/react-router/v3/index.d.ts @@ -0,0 +1,62 @@ +// Type definitions for react-router 3.0 +// Project: https://github.com/rackt/react-router +// Definitions by: Sergey Buturlakin +// Yuichi Murata +// Václav Ostrožlík +// Nathan Brown +// Alex Wendland +// Kostya Esmukov +// John Reilly +// Karol Janyst +// Dovydas Navickas +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export { + ChangeHook, + EnterHook, + InjectedRouter, + LeaveHook, + ParseQueryString, + RouteComponent, + RouteComponents, + RouteComponentProps, + RouteConfig, + RoutePattern, + RouterProps, + RouterState, + RedirectFunction, + StringifyQuery +} from "react-router/lib/Router"; +export { LinkProps } from "react-router/lib/Link"; +export { IndexLinkProps } from "react-router/lib/IndexLink"; +export { RouteProps, PlainRoute } from "react-router/lib/Route"; +export { IndexRouteProps } from "react-router/lib/IndexRoute"; +export { RedirectProps } from "react-router/lib/Redirect"; +export { IndexRedirectProps } from "react-router/lib/IndexRedirect"; + +/* components */ +export { default as Router } from "react-router/lib/Router"; +export { default as Link } from "react-router/lib/Link"; +export { default as IndexLink } from "react-router/lib/IndexLink"; +export { default as withRouter } from "react-router/lib/withRouter"; + +/* components (configuration) */ +export { default as IndexRedirect } from "react-router/lib/IndexRedirect"; +export { default as IndexRoute } from "react-router/lib/IndexRoute"; +export { default as Redirect } from "react-router/lib/Redirect"; +export { default as Route } from "react-router/lib/Route"; + +/* utils */ +export { createRoutes } from "react-router/lib/RouteUtils"; +export { default as RouterContext } from "react-router/lib/RouterContext"; +export { routerShape, locationShape } from "react-router/lib/PropTypes"; +export { default as match } from "react-router/lib/match"; +export { default as useRouterHistory } from "react-router/lib/useRouterHistory"; +export { formatPattern } from "react-router/lib/PatternUtils"; +export { default as applyRouterMiddleware } from "react-router/lib/applyRouterMiddleware"; + +/* histories */ +export { default as browserHistory } from "react-router/lib/browserHistory"; +export { default as hashHistory } from "react-router/lib/hashHistory"; +export { default as createMemoryHistory } from "react-router/lib/createMemoryHistory"; diff --git a/react-router/lib/IndexLink.d.ts b/react-router/v3/lib/IndexLink.d.ts similarity index 100% rename from react-router/lib/IndexLink.d.ts rename to react-router/v3/lib/IndexLink.d.ts diff --git a/react-router/lib/IndexRedirect.d.ts b/react-router/v3/lib/IndexRedirect.d.ts similarity index 100% rename from react-router/lib/IndexRedirect.d.ts rename to react-router/v3/lib/IndexRedirect.d.ts diff --git a/react-router/lib/IndexRoute.d.ts b/react-router/v3/lib/IndexRoute.d.ts similarity index 100% rename from react-router/lib/IndexRoute.d.ts rename to react-router/v3/lib/IndexRoute.d.ts diff --git a/react-router/lib/Link.d.ts b/react-router/v3/lib/Link.d.ts similarity index 100% rename from react-router/lib/Link.d.ts rename to react-router/v3/lib/Link.d.ts diff --git a/react-router/lib/PatternUtils.d.ts b/react-router/v3/lib/PatternUtils.d.ts similarity index 100% rename from react-router/lib/PatternUtils.d.ts rename to react-router/v3/lib/PatternUtils.d.ts diff --git a/react-router/lib/PropTypes.d.ts b/react-router/v3/lib/PropTypes.d.ts similarity index 100% rename from react-router/lib/PropTypes.d.ts rename to react-router/v3/lib/PropTypes.d.ts diff --git a/react-router/lib/Redirect.d.ts b/react-router/v3/lib/Redirect.d.ts similarity index 100% rename from react-router/lib/Redirect.d.ts rename to react-router/v3/lib/Redirect.d.ts diff --git a/react-router/lib/Route.d.ts b/react-router/v3/lib/Route.d.ts similarity index 100% rename from react-router/lib/Route.d.ts rename to react-router/v3/lib/Route.d.ts diff --git a/react-router/lib/RouteUtils.d.ts b/react-router/v3/lib/RouteUtils.d.ts similarity index 100% rename from react-router/lib/RouteUtils.d.ts rename to react-router/v3/lib/RouteUtils.d.ts diff --git a/react-router/lib/Router.d.ts b/react-router/v3/lib/Router.d.ts similarity index 100% rename from react-router/lib/Router.d.ts rename to react-router/v3/lib/Router.d.ts diff --git a/react-router/lib/RouterContext.d.ts b/react-router/v3/lib/RouterContext.d.ts similarity index 100% rename from react-router/lib/RouterContext.d.ts rename to react-router/v3/lib/RouterContext.d.ts diff --git a/react-router/lib/applyRouterMiddleware.d.ts b/react-router/v3/lib/applyRouterMiddleware.d.ts similarity index 100% rename from react-router/lib/applyRouterMiddleware.d.ts rename to react-router/v3/lib/applyRouterMiddleware.d.ts diff --git a/react-router/lib/browserHistory.d.ts b/react-router/v3/lib/browserHistory.d.ts similarity index 100% rename from react-router/lib/browserHistory.d.ts rename to react-router/v3/lib/browserHistory.d.ts diff --git a/react-router/lib/createMemoryHistory.d.ts b/react-router/v3/lib/createMemoryHistory.d.ts similarity index 100% rename from react-router/lib/createMemoryHistory.d.ts rename to react-router/v3/lib/createMemoryHistory.d.ts diff --git a/react-router/lib/hashHistory.d.ts b/react-router/v3/lib/hashHistory.d.ts similarity index 100% rename from react-router/lib/hashHistory.d.ts rename to react-router/v3/lib/hashHistory.d.ts diff --git a/react-router/lib/match.d.ts b/react-router/v3/lib/match.d.ts similarity index 100% rename from react-router/lib/match.d.ts rename to react-router/v3/lib/match.d.ts diff --git a/react-router/lib/useRouterHistory.d.ts b/react-router/v3/lib/useRouterHistory.d.ts similarity index 100% rename from react-router/lib/useRouterHistory.d.ts rename to react-router/v3/lib/useRouterHistory.d.ts diff --git a/react-router/lib/withRouter.d.ts b/react-router/v3/lib/withRouter.d.ts similarity index 100% rename from react-router/lib/withRouter.d.ts rename to react-router/v3/lib/withRouter.d.ts diff --git a/react-router/react-router-tests.tsx b/react-router/v3/react-router-tests.tsx similarity index 100% rename from react-router/react-router-tests.tsx rename to react-router/v3/react-router-tests.tsx diff --git a/react-router/v3/tsconfig.json b/react-router/v3/tsconfig.json new file mode 100644 index 0000000000..0f60e7a6ea --- /dev/null +++ b/react-router/v3/tsconfig.json @@ -0,0 +1,46 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "jsx": "react", + "baseUrl": "../../", + "typeRoots": ["../../"], + "paths": { + "history": ["history/v3"], + "history/*": ["history/v3/*"], + "react-router": ["react-router/v3"], + "react-router/*": ["react-router/v3/*"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "lib/applyRouterMiddleware.d.ts", + "lib/browserHistory.d.ts", + "lib/createMemoryHistory.d.ts", + "lib/hashHistory.d.ts", + "lib/IndexLink.d.ts", + "lib/IndexRedirect.d.ts", + "lib/IndexRoute.d.ts", + "lib/Link.d.ts", + "lib/match.d.ts", + "lib/PatternUtils.d.ts", + "lib/PropTypes.d.ts", + "lib/Redirect.d.ts", + "lib/Route.d.ts", + "lib/Router.d.ts", + "lib/RouterContext.d.ts", + "lib/RouteUtils.d.ts", + "lib/useRouterHistory.d.ts", + "lib/withRouter.d.ts", + "react-router-tests.tsx" + ] +} diff --git a/react-router/v3/tslint.json b/react-router/v3/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-router/v3/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From ee0f49ec1cd4b63aab4bbb630cb389db68f7e406 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Wed, 15 Mar 2017 11:11:30 +0100 Subject: [PATCH 2/5] Improve headers --- react-router-dom/index.d.ts | 1 + react-router/index.d.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/react-router-dom/index.d.ts b/react-router-dom/index.d.ts index 7b827ba3d5..e255eb69f3 100644 --- a/react-router-dom/index.d.ts +++ b/react-router-dom/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/ReactTraining/react-router // Definitions by: Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module 'react-router-dom' { import { diff --git a/react-router/index.d.ts b/react-router/index.d.ts index 1e0f01510c..8dfd32d02b 100644 --- a/react-router/index.d.ts +++ b/react-router/index.d.ts @@ -1,7 +1,17 @@ // Type definitions for React Router 4.0 // Project: https://github.com/ReactTraining/react-router -// Definitions by: Sergey Buturlakin , Yuichi Murata , Václav Ostrožlík , Nathan Brown , Alex Wendland , Kostya Esmukov , Tanguy Krotoff +// Definitions by: Sergey Buturlakin +// Yuichi Murata +// Václav Ostrožlík +// Nathan Brown +// Alex Wendland +// Kostya Esmukov +// John Reilly +// Karol Janyst +// Dovydas Navickas +// Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module 'react-router' { import * as React from 'react'; From 5da935de2b63c2d2eaed00af2a8723f42d9888d3 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 16 Mar 2017 09:32:41 +0100 Subject: [PATCH 3/5] Move all files from examples to test directory --- react-router/{examples => test}/Ambiguous.tsx | 0 react-router/{examples => test}/Animation.tsx | 0 react-router/{examples => test}/Auth.tsx | 0 react-router/{examples => test}/Basic.tsx | 0 .../{examples => test}/CustomLink.tsx | 0 .../{examples => test}/ModalGallery.tsx | 0 react-router/{examples => test}/NoMatch.tsx | 0 react-router/{examples => test}/Params.tsx | 0 .../PreventingTransitions.tsx | 0 react-router/{examples => test}/README.md | 0 react-router/{examples => test}/Recursive.tsx | 0 .../{examples => test}/RouteConfig.tsx | 0 react-router/{examples => test}/Sidebar.tsx | 0 react-router/tsconfig.json | 24 +++++++++---------- 14 files changed, 12 insertions(+), 12 deletions(-) rename react-router/{examples => test}/Ambiguous.tsx (100%) rename react-router/{examples => test}/Animation.tsx (100%) rename react-router/{examples => test}/Auth.tsx (100%) rename react-router/{examples => test}/Basic.tsx (100%) rename react-router/{examples => test}/CustomLink.tsx (100%) rename react-router/{examples => test}/ModalGallery.tsx (100%) rename react-router/{examples => test}/NoMatch.tsx (100%) rename react-router/{examples => test}/Params.tsx (100%) rename react-router/{examples => test}/PreventingTransitions.tsx (100%) rename react-router/{examples => test}/README.md (100%) rename react-router/{examples => test}/Recursive.tsx (100%) rename react-router/{examples => test}/RouteConfig.tsx (100%) rename react-router/{examples => test}/Sidebar.tsx (100%) diff --git a/react-router/examples/Ambiguous.tsx b/react-router/test/Ambiguous.tsx similarity index 100% rename from react-router/examples/Ambiguous.tsx rename to react-router/test/Ambiguous.tsx diff --git a/react-router/examples/Animation.tsx b/react-router/test/Animation.tsx similarity index 100% rename from react-router/examples/Animation.tsx rename to react-router/test/Animation.tsx diff --git a/react-router/examples/Auth.tsx b/react-router/test/Auth.tsx similarity index 100% rename from react-router/examples/Auth.tsx rename to react-router/test/Auth.tsx diff --git a/react-router/examples/Basic.tsx b/react-router/test/Basic.tsx similarity index 100% rename from react-router/examples/Basic.tsx rename to react-router/test/Basic.tsx diff --git a/react-router/examples/CustomLink.tsx b/react-router/test/CustomLink.tsx similarity index 100% rename from react-router/examples/CustomLink.tsx rename to react-router/test/CustomLink.tsx diff --git a/react-router/examples/ModalGallery.tsx b/react-router/test/ModalGallery.tsx similarity index 100% rename from react-router/examples/ModalGallery.tsx rename to react-router/test/ModalGallery.tsx diff --git a/react-router/examples/NoMatch.tsx b/react-router/test/NoMatch.tsx similarity index 100% rename from react-router/examples/NoMatch.tsx rename to react-router/test/NoMatch.tsx diff --git a/react-router/examples/Params.tsx b/react-router/test/Params.tsx similarity index 100% rename from react-router/examples/Params.tsx rename to react-router/test/Params.tsx diff --git a/react-router/examples/PreventingTransitions.tsx b/react-router/test/PreventingTransitions.tsx similarity index 100% rename from react-router/examples/PreventingTransitions.tsx rename to react-router/test/PreventingTransitions.tsx diff --git a/react-router/examples/README.md b/react-router/test/README.md similarity index 100% rename from react-router/examples/README.md rename to react-router/test/README.md diff --git a/react-router/examples/Recursive.tsx b/react-router/test/Recursive.tsx similarity index 100% rename from react-router/examples/Recursive.tsx rename to react-router/test/Recursive.tsx diff --git a/react-router/examples/RouteConfig.tsx b/react-router/test/RouteConfig.tsx similarity index 100% rename from react-router/examples/RouteConfig.tsx rename to react-router/test/RouteConfig.tsx diff --git a/react-router/examples/Sidebar.tsx b/react-router/test/Sidebar.tsx similarity index 100% rename from react-router/examples/Sidebar.tsx rename to react-router/test/Sidebar.tsx diff --git a/react-router/tsconfig.json b/react-router/tsconfig.json index c7af9e3fcf..c98755507a 100644 --- a/react-router/tsconfig.json +++ b/react-router/tsconfig.json @@ -14,17 +14,17 @@ }, "files": [ "index.d.ts", - "examples/Ambiguous.tsx", - "examples/Animation.tsx", - "examples/Auth.tsx", - "examples/Basic.tsx", - "examples/CustomLink.tsx", - "examples/ModalGallery.tsx", - "examples/NoMatch.tsx", - "examples/Params.tsx", - "examples/PreventingTransitions.tsx", - "examples/Recursive.tsx", - "examples/RouteConfig.tsx", - "examples/Sidebar.tsx" + "test/Ambiguous.tsx", + "test/Animation.tsx", + "test/Auth.tsx", + "test/Basic.tsx", + "test/CustomLink.tsx", + "test/ModalGallery.tsx", + "test/NoMatch.tsx", + "test/Params.tsx", + "test/PreventingTransitions.tsx", + "test/Recursive.tsx", + "test/RouteConfig.tsx", + "test/Sidebar.tsx" ] } From 029e384fa0531cdfcdf74fada54ebff5a899b32f Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 16 Mar 2017 09:52:31 +0100 Subject: [PATCH 4/5] Require TypeScript 2.2 due to the use of object --- react-router-dom/index.d.ts | 2 +- react-router/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/react-router-dom/index.d.ts b/react-router-dom/index.d.ts index e255eb69f3..b1c327cf80 100644 --- a/react-router-dom/index.d.ts +++ b/react-router-dom/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/ReactTraining/react-router // Definitions by: Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.2 declare module 'react-router-dom' { import { diff --git a/react-router/index.d.ts b/react-router/index.d.ts index 8dfd32d02b..f8482850b6 100644 --- a/react-router/index.d.ts +++ b/react-router/index.d.ts @@ -11,7 +11,7 @@ // Dovydas Navickas // Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.2 declare module 'react-router' { import * as React from 'react'; From d241778babf5c234b32b265676b228cc9459ffb5 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 16 Mar 2017 10:58:03 +0100 Subject: [PATCH 5/5] react-router-bootstrap should use react-router v3 --- react-router-bootstrap/tsconfig.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/react-router-bootstrap/tsconfig.json b/react-router-bootstrap/tsconfig.json index 8e586637c7..c41b83b04f 100644 --- a/react-router-bootstrap/tsconfig.json +++ b/react-router-bootstrap/tsconfig.json @@ -15,7 +15,9 @@ ], "paths": { "history": ["history/v3"], - "history/*": ["history/v3/*"] + "history/*": ["history/v3/*"], + "react-router": ["react-router/v3"], + "react-router/*": ["react-router/v3/*"] }, "types": [], "noEmit": true,