From 296fcf388e170b615f0dfa524a3040be60dddcc9 Mon Sep 17 00:00:00 2001 From: yhpnorra Date: Tue, 19 Dec 2017 17:31:01 +0800 Subject: [PATCH] fixed the lint one by one --- types/mirrorx/index.d.ts | 162 ++++++++++++++------------------- types/mirrorx/mirrorx-tests.ts | 10 +- 2 files changed, 73 insertions(+), 99 deletions(-) diff --git a/types/mirrorx/index.d.ts b/types/mirrorx/index.d.ts index 9cea8531dc..28a5fcf5ff 100644 --- a/types/mirrorx/index.d.ts +++ b/types/mirrorx/index.d.ts @@ -1,53 +1,39 @@ -// Type definitions for mirrorjs +// Type definitions for mirrorjs 0.2.10 // Project: https://github.com/mirrorjs/mirror // Definitions by: 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 = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]; + type Diff = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T]; type Omit = Pick>; 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 { 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 { 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. - ( - element: DOMElement, T>, - container: Element | null, - callback?: () => void + element: React.DOMElement, T>, + container: Element | null, + callback?: () => void ): T; ( - element: Array, any>>, - container: Element | null, - callback?: () => void + element: Array, any>>, + container: Element | null, + callback?: () => void ): Element; ( - element: SFCElement | Array>, - container: Element | null, - callback?: () => void + element: React.SFCElement | Array>, + container: Element | null, + callback?: () => void ): void; - >( - element: CElement, - container: Element | null, - callback?: () => void + >( + element: React.CElement, + container: Element | null, + callback?: () => void ): T; ( - element: Array>>, - container: Element | null, - callback?: () => void - ): Component; + element: Array>>, + container: Element | null, + callback?: () => void + ): React.Component;

( - element: ReactElement

, - container: Element | null, - callback?: () => void - ): Component | Element | void; + element: React.ReactElement

, + container: Element | null, + callback?: () => void + ): React.Component | Element | void; ( - element: Array>, - container: Element | null, - callback?: () => void - ): Component | Element | void; + element: Array>, + container: Element | null, + callback?: () => void + ): React.Component | Element | void; ( - parentComponent: Component | Array>, - element: SFCElement, - container: Element, - callback?: () => void + parentComponent: React.Component | Array>, + element: React.SFCElement, + 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 extends React.Component> {} - class Link extends React.Component {} - - class NavLink extends React.Component {} - + class Router extends React.Component> { } + class Link extends React.Component { } + class NavLink extends React.Component { } class Redirect extends React.Component { } - class Route extends React.Component { } - class Prompt extends React.Component { } - function withRouter

>(component: React.ComponentType

): React.ComponentClass>>; - function withRouter>(target: TFunction): TFunction; -} \ No newline at end of file +} diff --git a/types/mirrorx/mirrorx-tests.ts b/types/mirrorx/mirrorx-tests.ts index 11f1af29da..50d4f3dbe7 100644 --- a/types/mirrorx/mirrorx-tests.ts +++ b/types/mirrorx/mirrorx-tests.ts @@ -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(); } } });