mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-12 10:06:45 +08:00
redux-little-routers: remove typings, they are now upstream (#28681)
See https://github.com/FormidableLabs/redux-little-router/pull/269
This commit is contained in:
committed by
Ryan Cavanaugh
parent
8f134e436f
commit
dde8922b4c
@@ -1278,6 +1278,12 @@
|
||||
"sourceRepoURL": "https://github.com/zalmoxisus/redux-devtools-extension",
|
||||
"asOfVersion": "2.13.2"
|
||||
},
|
||||
{
|
||||
"libraryName": "redux-little-router",
|
||||
"typingsPackageName": "redux-little-router",
|
||||
"sourceRepoURL": "https://github.com/FormidableLabs/redux-little-router",
|
||||
"asOfVersion": "15.1.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "redux-persist",
|
||||
"typingsPackageName": "redux-persist",
|
||||
|
||||
171
types/redux-little-router/index.d.ts
vendored
171
types/redux-little-router/index.d.ts
vendored
@@ -1,171 +0,0 @@
|
||||
// Type definitions for redux-little-router 14.0
|
||||
// Project: https://github.com/FormidableLabs/redux-little-router
|
||||
// Definitions by: priecint <https://github.com/priecint>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from "react";
|
||||
import { Reducer, Middleware, StoreEnhancer } from "redux";
|
||||
|
||||
export interface Routes {
|
||||
[index: string]: RouteDefinition;
|
||||
}
|
||||
|
||||
export interface RouteDefinition {
|
||||
[index: string]: string | RouteDefinition;
|
||||
}
|
||||
|
||||
export interface LocationOptions {
|
||||
persistQuery?: boolean;
|
||||
}
|
||||
|
||||
export interface Query {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
export interface Params {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
export interface Location<TResult = {}> {
|
||||
pathname?: string;
|
||||
options?: LocationOptions;
|
||||
params?: Params;
|
||||
previous?: Location;
|
||||
query?: Query;
|
||||
result?: TResult;
|
||||
hash?: string;
|
||||
}
|
||||
|
||||
export interface BrowserRouterOptions {
|
||||
routes: Routes;
|
||||
basename?: string;
|
||||
}
|
||||
|
||||
export interface RouterState {
|
||||
router: Location;
|
||||
}
|
||||
|
||||
export function routerForBrowser(options: BrowserRouterOptions): {
|
||||
reducer: Reducer<RouterState>;
|
||||
middleware: Middleware;
|
||||
enhancer: StoreEnhancer<RouterState>;
|
||||
};
|
||||
|
||||
export interface ServerRouterOptions {
|
||||
routes: Routes;
|
||||
request: {
|
||||
path: string;
|
||||
baseUrl: string;
|
||||
url: string;
|
||||
query: {
|
||||
[key: string]: string;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function routerForExpress(options: ServerRouterOptions): {
|
||||
reducer: Reducer<Location>;
|
||||
middleware: Middleware;
|
||||
enhancer: StoreEnhancer<Location>;
|
||||
};
|
||||
|
||||
export interface HapiRouterOptions {
|
||||
routes: Routes;
|
||||
request: {
|
||||
path: string;
|
||||
url: string;
|
||||
query: {
|
||||
[key: string]: string;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function routerForHapi(options: HapiRouterOptions): {
|
||||
reducer: Reducer<Location>;
|
||||
middleware: Middleware;
|
||||
enhancer: StoreEnhancer<Location>;
|
||||
};
|
||||
|
||||
export function initializeCurrentLocation(location: Location): {
|
||||
type: string;
|
||||
payload: Location;
|
||||
};
|
||||
|
||||
export interface PersistentQueryLinkProps {
|
||||
className?: string;
|
||||
href: Href;
|
||||
persistQuery?: boolean;
|
||||
target?: string;
|
||||
onClick?: React.EventHandler<React.MouseEvent<HTMLAnchorElement>>;
|
||||
}
|
||||
|
||||
export interface LinkProps extends PersistentQueryLinkProps {
|
||||
replaceState?: boolean;
|
||||
}
|
||||
|
||||
export class Link extends React.Component<LinkProps, any> {
|
||||
}
|
||||
|
||||
export class PersistentQueryLink extends React.Component<PersistentQueryLinkProps, any> {
|
||||
}
|
||||
|
||||
export interface FragmentPropsForRoute {
|
||||
forRoute: string;
|
||||
}
|
||||
|
||||
export interface FragmentPropsWithConditions {
|
||||
withConditions: (location: Location) => boolean;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/q/37688318
|
||||
export type FragmentProps = FragmentPropsForRoute | FragmentPropsWithConditions | (FragmentPropsForRoute & FragmentPropsWithConditions);
|
||||
|
||||
export class Fragment extends React.Component<FragmentProps, any> {
|
||||
}
|
||||
|
||||
export type Href = string | Location;
|
||||
|
||||
export function push(href: Href, options?: LocationOptions): {
|
||||
type: string;
|
||||
payload: Location & {
|
||||
state: {
|
||||
reduxLittleRouter: {
|
||||
query: {};
|
||||
options: LocationOptions;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export function replace(href: Href, options?: LocationOptions): {
|
||||
type: string;
|
||||
payload: Location & {
|
||||
state: {
|
||||
reduxLittleRouter: {
|
||||
query: {};
|
||||
options: LocationOptions;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export function go(index: number): {
|
||||
type: string;
|
||||
payload: number;
|
||||
};
|
||||
|
||||
export function goBack(): {
|
||||
type: string;
|
||||
};
|
||||
|
||||
export function goForward(): {
|
||||
type: string;
|
||||
};
|
||||
|
||||
export const LOCATION_CHANGED: string;
|
||||
export const PUSH: string;
|
||||
export const REPLACE: string;
|
||||
export const GO: string;
|
||||
export const GO_BACK: string;
|
||||
export const GO_FORWARD: string;
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"redux": "^3.6.0"
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
import * as React from "react";
|
||||
import { createStore, compose, combineReducers, applyMiddleware, Reducer, Dispatch } from "redux";
|
||||
import { connect } from "react-redux";
|
||||
|
||||
import {
|
||||
Fragment,
|
||||
go,
|
||||
GO,
|
||||
GO_BACK,
|
||||
GO_FORWARD,
|
||||
goBack,
|
||||
goForward,
|
||||
Href,
|
||||
initializeCurrentLocation,
|
||||
Link,
|
||||
Location,
|
||||
LOCATION_CHANGED,
|
||||
LocationOptions,
|
||||
Params,
|
||||
push,
|
||||
PUSH,
|
||||
replace,
|
||||
REPLACE,
|
||||
routerForBrowser,
|
||||
RouterState
|
||||
} from "redux-little-router";
|
||||
|
||||
const goBackActionType: string = GO_BACK;
|
||||
const goForwardActionType: string = GO_FORWARD;
|
||||
const locationChangedActionType: string = LOCATION_CHANGED;
|
||||
const pushActionType: string = PUSH;
|
||||
const replaceActionType: string = REPLACE;
|
||||
|
||||
const {
|
||||
reducer,
|
||||
middleware,
|
||||
enhancer
|
||||
} = routerForBrowser({
|
||||
routes: {
|
||||
"/": {
|
||||
title: "Home"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const store = createStore<RouterState>(
|
||||
combineReducers({ router: reducer }),
|
||||
{ router: {} },
|
||||
compose(enhancer, applyMiddleware(middleware))
|
||||
);
|
||||
|
||||
const initialLocation = store.getState().router;
|
||||
|
||||
if (initialLocation) {
|
||||
store.dispatch(initializeCurrentLocation(initialLocation));
|
||||
}
|
||||
|
||||
interface TestProps {
|
||||
currentPath?: string;
|
||||
}
|
||||
|
||||
interface DispatchProps {
|
||||
go: (index: number) => void;
|
||||
goBack: () => void;
|
||||
goForward: () => void;
|
||||
push: (path: string) => void;
|
||||
replace: (path: string) => void;
|
||||
}
|
||||
|
||||
const TestComponent: React.SFC<TestProps & DispatchProps> = ({ currentPath }) => (
|
||||
<div>
|
||||
<Fragment forRoute="/">
|
||||
<div>
|
||||
Current Path: {currentPath}
|
||||
<Link href="/something" />
|
||||
</div>
|
||||
</Fragment>
|
||||
</div>
|
||||
);
|
||||
|
||||
const mapStateToProps = (state: RouterState): TestProps => ({
|
||||
currentPath: state.router.pathname
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch: Dispatch<{}>): DispatchProps => ({
|
||||
go: index => dispatch(go(index)),
|
||||
goBack: () => dispatch(goBack()),
|
||||
goForward: () => dispatch(goForward()),
|
||||
push: path => dispatch(push(path)),
|
||||
replace: path => dispatch(replace(path))
|
||||
});
|
||||
|
||||
const connectedTest = connect(mapStateToProps)(TestComponent);
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"jsx": "react",
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"redux-little-router-tests.tsx"
|
||||
]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user