diff --git a/react-router/index.d.ts.orig b/react-router/index.d.ts.orig deleted file mode 100644 index 52227f4d95..0000000000 --- a/react-router/index.d.ts.orig +++ /dev/null @@ -1,109 +0,0 @@ -<<<<<<< HEAD -// Type definitions for react-router 3.0 -======= -// Type definitions for react-router 2.0 ->>>>>>> upstream/master -// Project: https://github.com/rackt/react-router -// Definitions by: Sergey Buturlakin , Yuichi Murata , Václav Ostrožlík , Nathan Brown , Alex Wendland , Kostya Esmukov , Karol Janyst -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* Replacement from old history definitions */ -export interface HistoryOptions { - getCurrentLocation?(): Location; - getUserConfirmation?(message: string, callback: (result: boolean) => void): void; - pushLocation?(nextLocation: Location): void; - replaceLocation?(nextLocation: Location): void; - go?(n: number): void; - keyLength?: number; -} - -export type CreateHistory = (options?: HistoryOptions) => T; -export type CreateHistoryEnhancer = (createHistory: CreateHistory) => CreateHistory; - -<<<<<<< HEAD -export { - Basename, - ChangeHook, - EnterHook, - InjectedRouter, - LeaveHook, - Location, - LocationDescriptor, - ParseQueryString, - RouteComponent, - RouteComponents, - RouteComponentProps, - RouteConfig, - RoutePattern, - RouterProps, - RouterState, - StringifyQuery, - Query -} 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"; -======= -import * as React from 'react'; - -export const routerShape: React.Requireable; - -export const locationShape: React.Requireable; - -import Router from "./lib/Router"; -import Link from "./lib/Link"; -import IndexLink from "./lib/IndexLink"; -import IndexRedirect from "./lib/IndexRedirect"; -import IndexRoute from "./lib/IndexRoute"; -import Redirect from "./lib/Redirect"; -import Route from "./lib/Route"; -import * as History from "./lib/routerHistory"; -import Lifecycle from "./lib/Lifecycle"; -import RouteContext from "./lib/RouteContext"; -import browserHistory from "./lib/browserHistory"; -import hashHistory from "./lib/hashHistory"; -import useRoutes from "./lib/useRoutes"; -import { createRoutes } from "./lib/RouteUtils"; -import { formatPattern } from "./lib/PatternUtils"; -import RouterContext from "./lib/RouterContext"; -import PropTypes from "./lib/PropTypes"; -import match from "./lib/match"; -import useRouterHistory from "./lib/useRouterHistory"; -import createMemoryHistory from "./lib/createMemoryHistory"; -import withRouter from "./lib/withRouter"; -import applyRouterMiddleware from "./lib/applyRouterMiddleware"; - -// PlainRoute is defined in the API documented at: -// https://github.com/rackt/react-router/blob/master/docs/API.md -// but not included in any of the .../lib modules above. -export type PlainRoute = Router.PlainRoute; ->>>>>>> upstream/master - -/* 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/Route.d.ts.orig b/react-router/lib/Route.d.ts.orig deleted file mode 100644 index c8a211517c..0000000000 --- a/react-router/lib/Route.d.ts.orig +++ /dev/null @@ -1,49 +0,0 @@ -import { ComponentClass, ClassAttributes } from "react"; -import { LocationState } from "history"; -import { - EnterHook, - ChangeHook, - LeaveHook, - RouteComponent, - RouteComponents, - RoutePattern, - RouterState -} from "react-router"; -import { IndexRouteProps } from "react-router/lib/IndexRoute"; - -export interface RouteProps extends IndexRouteProps { - path?: RoutePattern; -} - -type Route = ComponentClass; -declare const Route: Route; - -<<<<<<< HEAD -export default Route; - -type RouteCallback = (err: any, route: PlainRoute) => void; -type RoutesCallback = (err: any, routesArray: PlainRoute[]) => void; - -export interface PlainRoute extends RouteProps { - childRoutes?: PlainRoute[]; - getChildRoutes?(partialNextState: LocationState, callback: RoutesCallback): void; - indexRoute?: PlainRoute; - getIndexRoute?(partialNextState: LocationState, callback: RouteCallback): void; -} -======= - interface RouteProps extends React.Props { - path?: Router.RoutePattern; - component?: Router.RouteComponent; - components?: Router.RouteComponents; - getComponent?: (nextState: Router.RouterState, cb: (error: any, component?: Router.RouteComponent) => void) => void; - getComponents?: (nextState: Router.RouterState, cb: (error: any, components?: Router.RouteComponents) => void) => void; - onEnter?: Router.EnterHook; - onLeave?: Router.LeaveHook; - onChange?: Router.ChangeHook; - getIndexRoute?: (location: Location, cb: (error: any, indexRoute: Router.RouteConfig) => void) => void; - getChildRoutes?: (location: Location, cb: (error: any, childRoutes: Router.RouteConfig) => void) => void; - } - interface Route extends React.ComponentClass {} - interface RouteElement extends React.ReactElement {} -} ->>>>>>> upstream/master diff --git a/react-router/lib/Router.d.ts.orig b/react-router/lib/Router.d.ts.orig deleted file mode 100644 index 8b77e41bdf..0000000000 --- a/react-router/lib/Router.d.ts.orig +++ /dev/null @@ -1,213 +0,0 @@ -import { Component, ComponentClass, ClassAttributes, ReactNode, StatelessComponent } from "react"; -import { - Action, - Hash, - History, - Href, - LocationKey, - LocationState, - Path, - Pathname, - Search -} from "history"; -import { PlainRoute } from "react-router"; - -/* Replacement from old history definitions */ -export type Basename = string; -export type Query = any; -export interface Params { - [key: string]: string; -} - -export type RoutePattern = string; -export type RouteComponent = ComponentClass | StatelessComponent; -export interface RouteComponents { - [name: string]: RouteComponent; -} -export type RouteConfig = ReactNode | PlainRoute | PlainRoute[]; - -export type ParseQueryString = (queryString: Search) => Query; -export type StringifyQuery = (queryObject: Query) => Search; - -type AnyFunction = (...args: any[]) => any; - -export type EnterHook = (nextState: RouterState, replace: RedirectFunction, callback?: AnyFunction) => any; -export type LeaveHook = (prevState: RouterState) => any; -export type ChangeHook = (prevState: RouterState, nextState: RouterState, replace: RedirectFunction, callback?: AnyFunction) => any; -export type RouteHook = (nextLocation?: Location) => any; - -<<<<<<< HEAD -export interface Location { - patname: Pathname; - search: Search; - query: Query; - state: LocationState; - action: Action; - key: LocationKey; -======= -// types based on https://github.com/rackt/react-router/blob/master/docs/Glossary.md - -declare namespace Router { - type RouteConfig = React.ReactNode | PlainRoute | PlainRoute[]; - type RoutePattern = string; - interface RouteComponents { [key: string]: RouteComponent; } - - type ParseQueryString = (queryString: QueryString) => Query; - type StringifyQuery = (queryObject: Query) => QueryString; - - type Component = React.ReactType; - type RouteComponent = Component; - - type EnterHook = (nextState: RouterState, replace: RedirectFunction, callback?: Function) => void; - type LeaveHook = () => void; - type ChangeHook = (prevState: RouterState, nextState: RouterState, replace: RedirectFunction, callback: Function) => void; - type RouteHook = (nextLocation?: Location) => any; - - interface Params { [param: string]: string; } - - type RouterListener = (error: Error, nextState: RouterState) => void; - - interface LocationDescriptor { - pathname?: Pathname; - query?: Query; - hash?: Href; - state?: HLocationState; - } - - interface RedirectFunction { - (location: LocationDescriptor): void; - /** - * @deprecated `replaceState(state, pathname, query) is deprecated; Use `replace(location)` with a location descriptor instead. http://tiny.cc/router-isActivedeprecated - */ - (state: HLocationState, pathname: Pathname | Path, query?: Query): void; - } - - interface RouterState { - location: Location; - routes: PlainRoute[]; - params: Params; - components: RouteComponent[]; - } - - interface RouterProps extends React.Props { - history?: History; - routes?: RouteConfig; // alias for children - createElement?: (component: RouteComponent, props: Object) => any; - onError?: (error: any) => any; - onUpdate?: () => any; - parseQueryString?: ParseQueryString; - stringifyQuery?: StringifyQuery; - basename?: string; - render?: (renderProps: React.Props<{}>) => RouterContext; - } - - interface PlainRoute { - path?: RoutePattern; - component?: RouteComponent; - components?: RouteComponents; - getComponent?: (location: Location, cb: (error: any, component?: RouteComponent) => void) => void; - getComponents?: (location: Location, cb: (error: any, components?: RouteComponents) => void) => void; - onEnter?: EnterHook; - onLeave?: LeaveHook; - indexRoute?: PlainRoute; - getIndexRoute?: (location: Location, cb: (error: any, indexRoute: RouteConfig) => void) => void; - childRoutes?: PlainRoute[]; - getChildRoutes?: (location: Location, cb: (error: any, childRoutes: RouteConfig) => void) => void; - } - - interface RouteComponentProps { - history?: History; - location?: Location; - params?: P; - route?: PlainRoute; - routeParams?: R; - routes?: PlainRoute[]; - children?: React.ReactElement; - } - - interface RouterOnContext extends History { - setRouteLeaveHook(route: PlainRoute, hook?: RouteHook): () => void; - isActive(pathOrLoc: Path | LocationDescriptor, indexOnly?: boolean): boolean; - } - - // Wrap a component using withRouter(Component) to provide a router object - // to the Component's props, allowing the Component to programmatically call - // push and other functions. - // - // https://github.com/reactjs/react-router/blob/v2.4.0/upgrade-guides/v2.4.0.md - - interface InjectedRouter { - push: (pathOrLoc: Path | LocationDescriptor) => void; - replace: (pathOrLoc: Path | LocationDescriptor) => void; - go: (n: number) => void; - goBack: () => void; - goForward: () => void; - setRouteLeaveHook(route: PlainRoute, callback: RouteHook): void; - createPath(path: History.Path, query?: History.Query): History.Path; - createHref(path: History.Path, query?: History.Query): History.Href; - isActive: (pathOrLoc: Path | LocationDescriptor, indexOnly?: boolean) => boolean; - } ->>>>>>> upstream/master -} - -export interface LocationDescriptorObject { - pathname?: Pathname; - query?: Query; - hash?: Hash; - state?: LocationState; -} - -export type LocationDescriptor = Path | LocationDescriptorObject; - -export interface RedirectFunction { - (location: LocationDescriptor): void; - (state: LocationState, pathname: Pathname | Path, query?: Query): void; -} - -export interface RouterState { - location: Location; - routes: PlainRoute[]; - params: Params; - components: RouteComponent[]; -} - -type LocationFunction = (location: LocationDescriptor) => void; -type GoFunction = (n: number) => void; -type NavigateFunction = () => void; -type ActiveFunction = (location: LocationDescriptor, indexOnly?: boolean) => boolean; -type LeaveHookFunction = (route: any, callback: RouteHook) => void; -type CreatePartFunction = (path: Path, query?: any) => Part; - -export interface InjectedRouter { - push: LocationFunction; - replace: LocationFunction; - go: GoFunction; - goBack: NavigateFunction; - goForward: NavigateFunction; - setRouteLeaveHook: LeaveHookFunction; - createPath: CreatePartFunction; - createHref: CreatePartFunction; - isActive: ActiveFunction; -} - -export interface RouteComponentProps { - location?: Location; - params?: P & R; - route?: PlainRoute; - router?: InjectedRouter; - routeParams?: R; -} - -export interface RouterProps extends ClassAttributes { - routes?: RouteConfig; - history?: History; - createElement?(component: RouteComponent, props: any): any; - onError?(error: any): any; - onUpdate?(): any; - render?(props: any): ReactNode; -} - -type Router = ComponentClass; -declare const Router: Router; - -export default Router; diff --git a/react-router/lib/useRouterHistory.d.ts.orig b/react-router/lib/useRouterHistory.d.ts.orig deleted file mode 100644 index 01609c5a48..0000000000 --- a/react-router/lib/useRouterHistory.d.ts.orig +++ /dev/null @@ -1,10 +0,0 @@ -import { History } from "history"; -import { CreateHistoryEnhancer } from "react-router"; - -<<<<<<< HEAD -declare const useRouterHistory: CreateHistoryEnhancer; - -export default useRouterHistory; -======= -export default function useRouterHistory(createHistory: CreateHistory): (options?: HistoryOptions) => History & HistoryQueries; ->>>>>>> upstream/master diff --git a/react-router/lib/withRouter.d.ts.orig b/react-router/lib/withRouter.d.ts.orig deleted file mode 100644 index ab51b2111e..0000000000 --- a/react-router/lib/withRouter.d.ts.orig +++ /dev/null @@ -1,14 +0,0 @@ -import { ComponentClass, StatelessComponent } from "react"; - -<<<<<<< HEAD -interface Options { - withRef?: boolean; -} - -type ComponentConstructor

= ComponentClass

| StatelessComponent

; - -export default function withRouter

(component: ComponentConstructor

, options?: Options): ComponentClass

; -======= -declare function withRouter | React.StatelessComponent | React.PureComponent>(component: C): C; -export default withRouter; ->>>>>>> upstream/master diff --git a/react-router/v2/tsconfig.json b/react-router/v2/tsconfig.json new file mode 100644 index 0000000000..7cc347abc4 --- /dev/null +++ b/react-router/v2/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "history": ["history/v2"], + "react-router": ["react-router/v2"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-router-redux-tests.ts" + ] +}