Remove unnecessary files, add tsconfig for old version

This commit is contained in:
Karol Janyst 2017-01-19 10:15:36 +09:00
parent cc4beb61ab
commit 5ce5e78468
6 changed files with 27 additions and 395 deletions

View File

@ -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 <https://github.com/sergey-buturlakin>, Yuichi Murata <https://github.com/mrk21>, Václav Ostrožlík <https://github.com/vasek17>, Nathan Brown <https://github.com/ngbrown>, Alex Wendland <https://github.com/awendland>, Kostya Esmukov <https://github.com/KostyaEsmukov>, Karol Janyst <https://github.com/LKay>
// 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<T> = (options?: HistoryOptions) => T;
export type CreateHistoryEnhancer<T> = (createHistory: CreateHistory<T>) => CreateHistory<T>;
<<<<<<< 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<any>;
export const locationShape: React.Requireable<any>;
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";

View File

@ -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<RouteProps>;
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<Route> {
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<RouteProps> {}
interface RouteElement extends React.ReactElement<RouteProps> {}
}
>>>>>>> upstream/master

View File

@ -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<any> | StatelessComponent<any>;
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<Router> {
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<P, R> {
history?: History;
location?: Location;
params?: P;
route?: PlainRoute;
routeParams?: R;
routes?: PlainRoute[];
children?: React.ReactElement<any>;
}
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<Part> = (path: Path, query?: any) => Part;
export interface InjectedRouter {
push: LocationFunction;
replace: LocationFunction;
go: GoFunction;
goBack: NavigateFunction;
goForward: NavigateFunction;
setRouteLeaveHook: LeaveHookFunction;
createPath: CreatePartFunction<Path>;
createHref: CreatePartFunction<Href>;
isActive: ActiveFunction;
}
export interface RouteComponentProps<P, R> {
location?: Location;
params?: P & R;
route?: PlainRoute;
router?: InjectedRouter;
routeParams?: R;
}
export interface RouterProps extends ClassAttributes<any> {
routes?: RouteConfig;
history?: History;
createElement?(component: RouteComponent, props: any): any;
onError?(error: any): any;
onUpdate?(): any;
render?(props: any): ReactNode;
}
type Router = ComponentClass<RouterProps>;
declare const Router: Router;
export default Router;

View File

@ -1,10 +0,0 @@
import { History } from "history";
import { CreateHistoryEnhancer } from "react-router";
<<<<<<< HEAD
declare const useRouterHistory: CreateHistoryEnhancer<History>;
export default useRouterHistory;
=======
export default function useRouterHistory<T>(createHistory: CreateHistory<T>): (options?: HistoryOptions) => History & HistoryQueries;
>>>>>>> upstream/master

View File

@ -1,14 +0,0 @@
import { ComponentClass, StatelessComponent } from "react";
<<<<<<< HEAD
interface Options {
withRef?: boolean;
}
type ComponentConstructor<P> = ComponentClass<P> | StatelessComponent<P>;
export default function withRouter<P>(component: ComponentConstructor<P>, options?: Options): ComponentClass<P>;
=======
declare function withRouter<C extends React.ComponentClass<any> | React.StatelessComponent<any> | React.PureComponent<any, any>>(component: C): C;
export default withRouter;
>>>>>>> upstream/master

View File

@ -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"
]
}