<commit_before>import * as React from 'react';
import RouterContext from './RouterContext';
import {
    QueryString, Query,
    Location, LocationDescriptor, LocationState as HLocationState,
    History, Href,
    Pathname, Path } from 'history';

declare const Router: Router;
interface Router extends React.ComponentClass<Router.RouterProps> { }

export default Router;

// 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;<commit_msg>React Router v2: `RouteComponentProps` non-optional `location` and `params`<commit_after>import * as React from 'react';
import RouterContext from './RouterContext';
import {
    QueryString, Query,
    Location, LocationDescriptor, LocationState as HLocationState,
    History, Href,
    Pathname, Path } from 'history';

declare const Router: Router;
interface Router extends React.ComponentClass<Router.RouterProps> { }

export default Router;

// 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;
{'fraction_non_alphanumeric': 0.11722543352601156, 'fraction_numerical': 0.0015028901734104045, 'mean_word_length': 3.165142031776601, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 63, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7233528', 'n_tokens_mistral': 2359, 'n_tokens_neox': 2314, 'n_words': 672}