fixed the lint one by one

This commit is contained in:
yhpnorra
2017-12-19 17:31:01 +08:00
parent d384da9dde
commit 296fcf388e
2 changed files with 73 additions and 99 deletions

View File

@@ -1,53 +1,39 @@
// Type definitions for mirrorjs
// Type definitions for mirrorjs 0.2.10
// Project: https://github.com/mirrorjs/mirror
// Definitions by: Aaronphy <https://github.com/aaronphy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
import * as React from 'react';
import * as H from 'history';
import {
ReactInstance, Component, ComponentState,
ReactElement, SFCElement, CElement,
DOMAttributes, DOMElement, ReactNode, ReactPortal
} from 'react';
import {
History,
Location,
Path,
LocationState,
LocationDescriptor
} from 'history';
import * as React from 'react';
import { Connect } from 'react-redux';
import { match } from "react-router";
export = mirror;
export as namespace mirror;
declare namespace mirror {
type Diff<T extends string, U extends string> = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T];
type Diff<T extends string, U extends string> = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T];
type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>;
interface model {
name:string,
initialState?:any,
reducers?:any,
effects?:any
}
interface _model {
name:string,
reducers:any
name: string;
initialState?: any;
reducers?: any;
effects?: any;
}
interface _model {
name: string;
reducers: any;
}
interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
to: H.LocationDescriptor;
replace?: boolean;
}
interface NavLinkProps extends LinkProps {
activeClassName?: string;
activeStyle?: React.CSSProperties;
@@ -99,121 +85,109 @@ declare namespace mirror {
}
interface RouterAction {
type:'@@router/CALL_HISTORY_METHOD',
type: '@@router/CALL_HISTORY_METHOD';
payload: LocationActionPayload;
}
interface routeActions {
push(location:any,state?:any):RouterAction,
replace(location:any,state?:any):RouterAction,
go(n:number):RouterAction,
goBack(): RouterAction,
goForward(): RouterAction
push(location: any, state?: any): RouterAction;
replace(location: any, state?: any): RouterAction;
go(n: number): RouterAction;
goBack(): RouterAction;
goForward(): RouterAction;
}
export interface ConnectedRouterProps<State> {
store?: any;
history?: History;
}
history?: H.History;
}
interface Actions {
routing:routeActions,
[propName: string]: any
routing: routeActions;
[propName: string]: any;
}
interface defaultOptions {
initialState?:{},
historyMode?:string,
middlewares:any[],
reducers:{},
addEffect(name:string,handler:()=>any):any
initialState?: {};
historyMode?: string;
middlewares: any[];
reducers: {};
addEffect(name: string, handler: () => any): any;
}
interface Renderer {
// Deprecated(render): The return value is deprecated.
// In future releases the render function's return type will be void.
<T extends Element>(
element: DOMElement<DOMAttributes<T>, T>,
container: Element | null,
callback?: () => void
element: React.DOMElement<React.DOMAttributes<T>, T>,
container: Element | null,
callback?: () => void
): T;
(
element: Array<DOMElement<DOMAttributes<any>, any>>,
container: Element | null,
callback?: () => void
element: Array<React.DOMElement<React.DOMAttributes<any>, any>>,
container: Element | null,
callback?: () => void
): Element;
(
element: SFCElement<any> | Array<SFCElement<any>>,
container: Element | null,
callback?: () => void
element: React.SFCElement<any> | Array<React.SFCElement<any>>,
container: Element | null,
callback?: () => void
): void;
<P, T extends Component<P, ComponentState>>(
element: CElement<P, T>,
container: Element | null,
callback?: () => void
<P, T extends React.Component<P, React.ComponentState>>(
element: React.CElement<P, T>,
container: Element | null,
callback?: () => void
): T;
(
element: Array<CElement<any, Component<any, ComponentState>>>,
container: Element | null,
callback?: () => void
): Component<any, ComponentState>;
element: Array<React.CElement<any, React.Component<any, React.ComponentState>>>,
container: Element | null,
callback?: () => void
): React.Component<any, React.ComponentState>;
<P>(
element: ReactElement<P>,
container: Element | null,
callback?: () => void
): Component<P, ComponentState> | Element | void;
element: React.ReactElement<P>,
container: Element | null,
callback?: () => void
): React.Component<P, React.ComponentState> | Element | void;
(
element: Array<ReactElement<any>>,
container: Element | null,
callback?: () => void
): Component<any, ComponentState> | Element | void;
element: Array<React.ReactElement<any>>,
container: Element | null,
callback?: () => void
): React.Component<any, React.ComponentState> | Element | void;
(
parentComponent: Component<any> | Array<Component<any>>,
element: SFCElement<any>,
container: Element,
callback?: () => void
parentComponent: React.Component<any> | Array<React.Component<any>>,
element: React.SFCElement<any>,
container: Element,
callback?: () => void
): void;
}
}
/**
* This method is used to create and inject a model.
* @param options
* @param options
*/
function model(options:model):_model
function model(options: model): _model;
/**
* connect connects your React component to your Redux store
*/
const connect:Connect
//The actions object contains both your Redux actions and reducers.
const actions:Actions
//Add a hook to monitor actions that have been dispatched.
const hook:(subscriber:()=>any)=>any
//mirror.defaults is a pretty intuitive API, you use it to configure your Mirror app.
const defaults:(options:defaultOptions)=>void
//render is an enhanced ReactDOM.render, it starts your Mirror app.
const connect: Connect;
const actions: Actions;
const hook: (subscriber: () => any) => any;
const defaults: (options: defaultOptions) => void;
const render: Renderer;
// Mirror uses react-router@4.x, so if you're from react-router 2.x/3.x, you should checkout the Migrating from v2/v3 to v4 Guide.
class Router<State> extends React.Component<ConnectedRouterProps<State>> {}
class Link extends React.Component<LinkProps, any> {}
class NavLink extends React.Component<NavLinkProps, any> {}
class Router<State> extends React.Component<ConnectedRouterProps<State>> { }
class Link extends React.Component<LinkProps, any> { }
class NavLink extends React.Component<NavLinkProps, any> { }
class Redirect extends React.Component<RedirectProps, any> { }
class Route<T extends RouteProps = RouteProps> extends React.Component<T, any> { }
class Prompt extends React.Component<PromptProps, any> { }
function withRouter<P extends RouteComponentProps<any>>(component: React.ComponentType<P>): React.ComponentClass<Omit<P, keyof RouteComponentProps<any>>>;
function withRouter<P, TFunction extends React.ComponentClass<P>>(target: TFunction): TFunction;
}
}

View File

@@ -1,9 +1,9 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import mirror, { actions } from 'mirrorx';
/**
* add mirror.model.tests
*/
import mirror = require('mirrorx');
/**
* add mirror.model.tests
*/
mirror.model({
name: 'app',
initialState: 0,
@@ -18,7 +18,7 @@ mirror.model({
resolve();
}, 1000);
});
actions.app.increment();
mirror.actions.app.increment();
}
}
});