Commit deb14330 authored by 陈帅's avatar 陈帅

support use typescript

parent e7b77ff2
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
"lint:fix": "eslint --fix --ext .js src mock tests && npm run lint:style", "lint:fix": "eslint --fix --ext .js src mock tests && npm run lint:style",
"lint-staged": "lint-staged", "lint-staged": "lint-staged",
"lint-staged:js": "eslint --ext .js", "lint-staged:js": "eslint --ext .js",
"tslint": "npm run tslint:fix",
"tslint:fix": "tslint --fix 'src/**/*.ts*'",
"test": "umi test", "test": "umi test",
"test:component": "umi test ./src/components", "test:component": "umi test ./src/components",
"test:all": "node ./tests/run-tests.js", "test:all": "node ./tests/run-tests.js",
...@@ -71,6 +73,9 @@ ...@@ -71,6 +73,9 @@
"eslint-plugin-jsx-a11y": "^6.1.2", "eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-markdown": "^1.0.0-beta.6", "eslint-plugin-markdown": "^1.0.0-beta.6",
"eslint-plugin-react": "^7.11.1", "eslint-plugin-react": "^7.11.1",
"tslint": "^5.10.0",
"tslint-config-prettier": "^1.10.0",
"tslint-react": "^3.6.0",
"gh-pages": "^2.0.1", "gh-pages": "^2.0.1",
"husky": "^1.1.2", "husky": "^1.1.2",
"lint-staged": "^7.2.0", "lint-staged": "^7.2.0",
......
import * as React from 'react';
import { RouteProps } from 'react-router';
type authorityFN = (currentAuthority?: string) => boolean;
type authority = string | string[] | authorityFN | Promise<any>;
export interface IAuthorizedRouteProps extends RouteProps {
authority: authority;
}
export { authority };
export class AuthorizedRoute extends React.Component<IAuthorizedRouteProps, any> {}
import * as React from 'react'; import * as React from 'react';
import { RouteProps } from 'react-router'; import AuthorizedRoute, { authority } from './AuthorizedRoute';
type authorityFN = (currentAuthority?: string) => boolean;
type authority = string | Array<string> | authorityFN | Promise<any>;
export type IReactComponent<P = any> = export type IReactComponent<P = any> =
| React.StatelessComponent<P> | React.StatelessComponent<P>
| React.ComponentClass<P> | React.ComponentClass<P>
| React.ClassicComponentClass<P>; | React.ClassicComponentClass<P>;
interface Secured { type Secured = (
(authority: authority, error?: React.ReactNode): <T extends IReactComponent>(target: T) => T; authority: authority,
} error?: React.ReactNode
) => <T extends IReactComponent>(target: T) => T;
export interface AuthorizedRouteProps extends RouteProps {
authority: authority;
}
export class AuthorizedRoute extends React.Component<AuthorizedRouteProps, any> {}
interface check { type check = <T extends IReactComponent, S extends IReactComponent>(
<T extends IReactComponent, S extends IReactComponent>( authority: authority,
authority: authority, target: T,
target: T, Exception: S
Exception: S ) => T | S;
): T | S;
}
export interface AuthorizedProps { export interface IAuthorizedProps {
authority: authority; authority: authority;
noMatch?: React.ReactNode; noMatch?: React.ReactNode;
} }
export class Authorized extends React.Component<AuthorizedProps, any> { export class Authorized extends React.Component<IAuthorizedProps, any> {
static Secured: Secured; public static Secured: Secured;
static AuthorizedRoute: typeof AuthorizedRoute; public static AuthorizedRoute: typeof AuthorizedRoute;
static check: check; public static check: check;
} }
declare function renderAuthorize(currentAuthority: string): typeof Authorized; declare function renderAuthorize(currentAuthority: string): typeof Authorized;
......
import * as React from 'react';
import { CardProps } from 'antd/lib/card'; import { CardProps } from 'antd/lib/card';
import * as React from 'react';
export interface IChartCardProps extends CardProps { export interface IChartCardProps extends CardProps {
title: React.ReactNode; title: React.ReactNode;
......
import * as React from 'react';
export interface ILoginItemProps {
name?: string;
rules?: any[];
style?: React.CSSProperties;
onGetCaptcha?: () => void;
placeholder?: string;
buttonText?: React.ReactNode;
}
export class LoginItem extends React.Component<ILoginItemProps, any> {}
import * as React from 'react';
export interface ILoginTabProps {
key?: string;
tab?: React.ReactNode;
}
export default class LoginTab extends React.Component<ILoginTabProps, any> {}
import * as React from 'react';
import Button from 'antd/lib/button'; import Button from 'antd/lib/button';
export interface LoginProps { import * as React from 'react';
import LoginItem from './LoginItem';
import LoginTab from './LoginTab';
export interface ILoginProps {
defaultActiveKey?: string; defaultActiveKey?: string;
onTabChange?: (key: string) => void; onTabChange?: (key: string) => void;
style?: React.CSSProperties; style?: React.CSSProperties;
onSubmit?: (error: any, values: any) => void; onSubmit?: (error: any, values: any) => void;
} }
export interface TabProps { export default class Login extends React.Component<ILoginProps, any> {
key?: string; public static Tab: typeof LoginTab;
tab?: React.ReactNode; public static UserName: typeof LoginItem;
} public static Password: typeof LoginItem;
export class Tab extends React.Component<TabProps, any> {} public static Mobile: typeof LoginItem;
public static Captcha: typeof LoginItem;
export interface LoginItemProps { public static Submit: typeof Button;
name?: string;
rules?: any[];
style?: React.CSSProperties;
onGetCaptcha?: () => void;
placeholder?: string;
buttonText?: React.ReactNode;
}
export class LoginItem extends React.Component<LoginItemProps, any> {}
export default class Login extends React.Component<LoginProps, any> {
static Tab: typeof Tab;
static UserName: typeof LoginItem;
static Password: typeof LoginItem;
static Mobile: typeof LoginItem;
static Captcha: typeof LoginItem;
static Submit: typeof Button;
} }
import * as React from 'react'; import * as React from 'react';
import { IPageHeaderProps } from './index' import { IPageHeaderProps } from './index';
export default class BreadcrumbView extends React.Component<IPageHeaderProps, any> {} export default class BreadcrumbView extends React.Component<IPageHeaderProps, any> {}
export function getBreadcrumb(breadcrumbNameMap: Object, url: string): Object; export function getBreadcrumb(breadcrumbNameMap: object, url: string): object;
{
"compilerOptions": {
"outDir": "build/dist",
"module": "esnext",
"target": "es2016",
"lib": ["es6", "dom"],
"sourceMap": true,
"baseUrl": ".",
"jsx": "react",
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"rootDirs": ["/src", "/test", "/mock","./typings"],
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"allowJs": true,
"experimentalDecorators": true,
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["./src"],
"exclude": [
"node_modules",
"build",
"scripts",
"acceptance-tests",
"webpack",
"jest",
"src/setupTests.ts",
"tslint:latest",
"tslint-config-prettier"
]
}
{
"extends": ["tslint:latest", "tslint-react", "tslint-config-prettier"],
"rules": {
"no-var-requires": false,
"no-submodule-imports": false,
"object-literal-sort-keys": false,
"jsx-no-lambda": false,
"no-implicit-dependencies": false,
"no-console": false
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment