diff --git a/components/alert/index.tsx b/components/alert/index.tsx index 826815869f..d2759411f5 100755 --- a/components/alert/index.tsx +++ b/components/alert/index.tsx @@ -18,7 +18,7 @@ export interface AlertProps { /** Additional content of Alert */ description?: React.ReactNode; /** Callback when close Alert */ - onClose?: React.MouseEventHandler; + onClose?: React.MouseEventHandler; /** Whether to show icon */ showIcon?: boolean; style?: React.CSSProperties; diff --git a/components/back-top/index.tsx b/components/back-top/index.tsx index c8f8815d9e..091c58a076 100755 --- a/components/back-top/index.tsx +++ b/components/back-top/index.tsx @@ -25,7 +25,7 @@ const easeInOutCubic = (t, b, c, d) => { export interface BackTopProps { visibilityHeight?: number; - onClick?: React.MouseEventHandler; + onClick?: React.MouseEventHandler; target?: () => HTMLElement | Window; prefixCls?: string; className?: string; diff --git a/components/button/button.tsx b/components/button/button.tsx index f2f6f73aff..137de252c9 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -34,8 +34,8 @@ export interface ButtonProps { icon?: string; shape?: ButtonShape; size?: ButtonSize; - onClick?: React.FormEventHandler; - onMouseUp?: React.FormEventHandler; + onClick?: React.FormEventHandler; + onMouseUp?: React.FormEventHandler; loading?: boolean; disabled?: boolean; style?: React.CSSProperties; diff --git a/components/checkbox/index.tsx b/components/checkbox/index.tsx index 8c69327f4d..8745839ffa 100644 --- a/components/checkbox/index.tsx +++ b/components/checkbox/index.tsx @@ -13,7 +13,7 @@ export interface CheckboxProps { /** indeterminate 状态,只负责样式控制 */ indeterminate?: boolean; /** 变化时回调函数 */ - onChange?: React.FormEventHandler; + onChange?: React.FormEventHandler; style?: React.CSSProperties; disabled?: boolean; className?: string; diff --git a/components/dropdown/dropdown-button.tsx b/components/dropdown/dropdown-button.tsx index ef04225fe5..3e1d361801 100644 --- a/components/dropdown/dropdown-button.tsx +++ b/components/dropdown/dropdown-button.tsx @@ -8,7 +8,7 @@ import splitObject from '../_util/splitObject'; export interface DropdownButtonProps { type?: 'primary' | 'ghost' | 'dash'; - onClick?: React.FormEventHandler; + onClick?: React.FormEventHandler; trigger?: 'click' | 'hover'; overlay: React.ReactNode; visible?: boolean; diff --git a/components/form/Form.tsx b/components/form/Form.tsx index e3e335a830..d0e9fb7113 100755 --- a/components/form/Form.tsx +++ b/components/form/Form.tsx @@ -20,7 +20,7 @@ export interface FormProps { inline?: boolean; vertical?: boolean; form?: WrappedFormUtils; - onSubmit?: React.FormEventHandler; + onSubmit?: React.FormEventHandler; style?: React.CSSProperties; className?: string; prefixCls?: string; diff --git a/components/icon/index.tsx b/components/icon/index.tsx index 4460b49e3a..7e3de5a03f 100755 --- a/components/icon/index.tsx +++ b/components/icon/index.tsx @@ -6,7 +6,7 @@ export interface IconProps { type: string; className?: string; title?: string; - onClick?: React.MouseEventHandler; + onClick?: React.MouseEventHandler; spin?: boolean; } diff --git a/components/input/Input.tsx b/components/input/Input.tsx index d857a0c194..012d03cd9a 100644 --- a/components/input/Input.tsx +++ b/components/input/Input.tsx @@ -45,11 +45,11 @@ export interface InputProps { readOnly?: boolean; addonBefore?: React.ReactNode; addonAfter?: React.ReactNode; - onPressEnter?: React.FormEventHandler; - onKeyDown?: React.FormEventHandler; - onChange?: React.FormEventHandler; - onClick?: React.FormEventHandler; - onBlur?: React.FormEventHandler; + onPressEnter?: React.FormEventHandler; + onKeyDown?: React.FormEventHandler; + onChange?: React.FormEventHandler; + onClick?: React.FormEventHandler; + onBlur?: React.FormEventHandler; autosize?: boolean | AutoSizeType; autoComplete?: 'on' | 'off'; style?: React.CSSProperties; diff --git a/components/modal/Modal.tsx b/components/modal/Modal.tsx index 0fb94933cf..93ff9c2be0 100644 --- a/components/modal/Modal.tsx +++ b/components/modal/Modal.tsx @@ -21,7 +21,7 @@ export interface ModalProps { /** 点击确定回调*/ onOk?: () => void; /** 点击模态框右上角叉、取消按钮、Props.maskClosable 值为 true 时的遮罩层或键盘按下 Esc 时的回调*/ - onCancel?: (e: React.MouseEvent) => void; + onCancel?: (e: React.MouseEvent) => void; /** 宽度*/ width?: string | number; /** 底部内容*/ diff --git a/components/radio/group.tsx b/components/radio/group.tsx index d6c0c9b9a0..ffbc3fa784 100644 --- a/components/radio/group.tsx +++ b/components/radio/group.tsx @@ -19,7 +19,7 @@ function getCheckedValue(children) { export interface RadioGroupProps { /** 选项变化时的回调函数*/ - onChange?: React.FormEventHandler; + onChange?: React.FormEventHandler; /** 用于设置当前选中的值*/ value?: string | number; /** 默认选中的值*/ diff --git a/components/table/filterDropdown.tsx b/components/table/filterDropdown.tsx index 5e25cf88de..93242288bb 100755 --- a/components/table/filterDropdown.tsx +++ b/components/table/filterDropdown.tsx @@ -6,7 +6,7 @@ import Checkbox from '../checkbox'; import Radio from '../radio'; export interface FilterDropdownMenuWrapperProps { - onClick?: React.MouseEventHandler; + onClick?: React.MouseEventHandler; children?: any; className?: string; } diff --git a/components/transfer/operation.tsx b/components/transfer/operation.tsx index 277d16e86f..99c992c4da 100644 --- a/components/transfer/operation.tsx +++ b/components/transfer/operation.tsx @@ -9,8 +9,8 @@ export interface TransferOperationProps { className?: string; leftArrowText?: string; rightArrowText?: string; - moveToLeft?: React.FormEventHandler; - moveToRight?: React.FormEventHandler; + moveToLeft?: React.FormEventHandler; + moveToRight?: React.FormEventHandler; leftActive?: boolean; rightActive?: boolean; } diff --git a/components/transfer/search.tsx b/components/transfer/search.tsx index 6cfd8c740e..ba69224290 100644 --- a/components/transfer/search.tsx +++ b/components/transfer/search.tsx @@ -8,8 +8,8 @@ function noop() { export interface SearchProps { prefixCls?: string; placeholder?: string; - onChange?: (e: React.FormEvent) => void; - handleClear?: (e: React.MouseEvent) => void; + onChange?: (e: React.FormEvent) => void; + handleClear?: (e: React.MouseEvent) => void; value?: any; } diff --git a/components/tree/index.tsx b/components/tree/index.tsx index d04118373f..4380838b22 100644 --- a/components/tree/index.tsx +++ b/components/tree/index.tsx @@ -27,7 +27,7 @@ export interface AntTreeNodeEvent { export interface AntTreeNodeMouseEvent { node: AntTreeNode; - event: React.MouseEventHandler; + event: React.MouseEventHandler; } export interface TreeProps { diff --git a/package.json b/package.json index 0887ef9aba..2344998ae4 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,9 @@ "warning": "~3.0.0" }, "devDependencies": { - "antd-tools": "^0.12.0", + "@types/react": "~0.14.41", + "@types/react-dom": "~0.14.18", + "antd-tools": "^0.13.0", "babel-eslint": "^6.0.2", "babel-jest": "^13.2.2", "babel-plugin-import": "^1.0.0", diff --git a/tsconfig.json b/tsconfig.json index c77931336e..36444138b3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "strictNullChecks": false, "moduleResolution": "node", "allowSyntheticDefaultImports": true, "jsx": "preserve", diff --git a/typings.json b/typings.json deleted file mode 100644 index e530d9268b..0000000000 --- a/typings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "globalDependencies": { - "react": "registry:dt/react#0.14.0+20160720060442", - "react-dom": "registry:dt/react-dom#0.14.0+20160412154040" - } -} diff --git a/typings/globals/react-dom/index.d.ts b/typings/globals/react-dom/index.d.ts deleted file mode 100644 index a38e3e806f..0000000000 --- a/typings/globals/react-dom/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/b9642fb8ac07f7164dc643ddd1fa99b58ae9be8b/react/react-dom.d.ts -declare namespace __React { - namespace __DOM { - function findDOMNode(instance: ReactInstance): E; - function findDOMNode(instance: ReactInstance): Element; - - function render

( - element: DOMElement, - container: Element, - callback?: (element: T) => any): T; - function render

( - element: SFCElement

, - container: Element, - callback?: () => any): void; - function render>( - element: CElement, - container: Element, - callback?: (component: T) => any): T; - function render

( - element: ReactElement

, - container: Element, - callback?: (component?: Component | Element) => any): Component | Element | void; - - function unmountComponentAtNode(container: Element): boolean; - - var version: string; - - function unstable_batchedUpdates(callback: (a: A, b: B) => any, a: A, b: B): void; - function unstable_batchedUpdates(callback: (a: A) => any, a: A): void; - function unstable_batchedUpdates(callback: () => any): void; - - function unstable_renderSubtreeIntoContainer

( - parentComponent: Component, - element: DOMElement, - container: Element, - callback?: (element: T) => any): T; - function unstable_renderSubtreeIntoContainer>( - parentComponent: Component, - element: CElement, - container: Element, - callback?: (component: T) => any): T; - function render

( - parentComponent: Component, - element: SFCElement

, - container: Element, - callback?: () => any): void; - function unstable_renderSubtreeIntoContainer

( - parentComponent: Component, - element: ReactElement

, - container: Element, - callback?: (component?: Component | Element) => any): Component | Element | void; - } - - namespace __DOMServer { - function renderToString(element: ReactElement): string; - function renderToStaticMarkup(element: ReactElement): string; - var version: string; - } -} - -declare module "react-dom" { - import DOM = __React.__DOM; - export = DOM; -} - -declare module "react-dom/server" { - import DOMServer = __React.__DOMServer; - export = DOMServer; -} diff --git a/typings/globals/react-dom/typings.json b/typings/globals/react-dom/typings.json deleted file mode 100644 index 805a35836d..0000000000 --- a/typings/globals/react-dom/typings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "resolution": "main", - "tree": { - "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/b9642fb8ac07f7164dc643ddd1fa99b58ae9be8b/react/react-dom.d.ts", - "raw": "registry:dt/react-dom#0.14.0+20160412154040", - "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/b9642fb8ac07f7164dc643ddd1fa99b58ae9be8b/react/react-dom.d.ts" - } -} diff --git a/typings/globals/react/index.d.ts b/typings/globals/react/index.d.ts deleted file mode 100644 index 457ab043b3..0000000000 --- a/typings/globals/react/index.d.ts +++ /dev/null @@ -1,2514 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/03cd162da057a9cbf653119982e12233ae2b90a6/react/react.d.ts -declare namespace __React { - - // - // React Elements - // ---------------------------------------------------------------------- - - type ReactType = string | ComponentClass | StatelessComponent; - - type Key = string | number; - type Ref = string | ((instance: T) => any); - type ComponentState = {} | void; - - interface Attributes { - key?: Key; - } - interface ClassAttributes extends Attributes { - ref?: Ref; - } - - interface ReactElement

{ - type: string | ComponentClass

| SFC

; - props: P; - key?: Key; - } - - interface SFCElement

extends ReactElement

{ - type: SFC

; - } - - type CElement> = ComponentElement; - interface ComponentElement> extends ReactElement

{ - type: ComponentClass

; - ref?: Ref; - } - - type ClassicElement

= CElement>; - - interface DOMElement

extends ReactElement

{ - type: string; - ref: Ref; - } - - interface ReactHTMLElement extends DOMElement { - } - - interface ReactSVGElement extends DOMElement { - } - - // - // Factories - // ---------------------------------------------------------------------- - - interface Factory

{ - (props?: P & Attributes, ...children: ReactNode[]): ReactElement

; - } - - interface SFCFactory

{ - (props?: P & Attributes, ...children: ReactNode[]): SFCElement

; - } - - interface ComponentFactory> { - (props?: P & ClassAttributes, ...children: ReactNode[]): CElement; - } - - type CFactory> = ComponentFactory; - type ClassicFactory

= CFactory>; - - interface DOMFactory

{ - (props?: P & ClassAttributes, ...children: ReactNode[]): DOMElement; - } - - interface HTMLFactory extends DOMFactory { - } - - interface SVGFactory extends DOMFactory { - } - - // - // React Nodes - // http://facebook.github.io/react/docs/glossary.html - // ---------------------------------------------------------------------- - - type ReactText = string | number; - type ReactChild = ReactElement | ReactText; - - // Should be Array but type aliases cannot be recursive - type ReactFragment = {} | Array; - type ReactNode = ReactChild | ReactFragment | boolean; - - // - // Top Level API - // ---------------------------------------------------------------------- - - function createClass(spec: ComponentSpec): ClassicComponentClass

; - - function createFactory

( - type: string): DOMFactory; - function createFactory

(type: SFC

): SFCFactory

; - function createFactory

( - type: ClassType, ClassicComponentClass

>): CFactory>; - function createFactory, C extends ComponentClass

>( - type: ClassType): CFactory; - function createFactory

(type: ComponentClass

| SFC

): Factory

; - - function createElement

( - type: string, - props?: P & ClassAttributes, - ...children: ReactNode[]): DOMElement; - function createElement

( - type: SFC

, - props?: P & Attributes, - ...children: ReactNode[]): SFCElement

; - function createElement

( - type: ClassType, ClassicComponentClass

>, - props?: P & ClassAttributes>, - ...children: ReactNode[]): CElement>; - function createElement, C extends ComponentClass

>( - type: ClassType, - props?: P & ClassAttributes, - ...children: ReactNode[]): CElement; - function createElement

( - type: ComponentClass

| SFC

, - props?: P & Attributes, - ...children: ReactNode[]): ReactElement

; - - function cloneElement

( - element: DOMElement, - props?: P & ClassAttributes, - ...children: ReactNode[]): DOMElement; - function cloneElement

( - element: SFCElement

, - props?: Q, // should be Q & Attributes, but then Q is inferred as {} - ...children: ReactNode[]): SFCElement

; - function cloneElement

>( - element: CElement, - props?: Q, // should be Q & ClassAttributes - ...children: ReactNode[]): CElement; - function cloneElement

( - element: ReactElement

, - props?: Q, // should be Q & Attributes - ...children: ReactNode[]): ReactElement

; - - function isValidElement

(object: {}): object is ReactElement

; - - var DOM: ReactDOM; - var PropTypes: ReactPropTypes; - var Children: ReactChildren; - var version: string; - - // - // Component API - // ---------------------------------------------------------------------- - - type ReactInstance = Component | Element; - - // Base component for plain JS classes - class Component implements ComponentLifecycle { - constructor(props?: P, context?: any); - setState(f: (prevState: S, props: P) => S, callback?: () => any): void; - setState(state: S, callback?: () => any): void; - forceUpdate(callback?: () => any): void; - render(): JSX.Element; - - // React.Props is now deprecated, which means that the `children` - // property is not available on `P` by default, even though you can - // always pass children as variadic arguments to `createElement`. - // In the future, if we can define its call signature conditionally - // on the existence of `children` in `P`, then we should remove this. - props: P & { children?: ReactNode }; - state: S; - context: {}; - refs: { - [key: string]: ReactInstance - }; - } - - interface ClassicComponent extends Component { - replaceState(nextState: S, callback?: () => any): void; - isMounted(): boolean; - getInitialState?(): S; - } - - interface ChildContextProvider { - getChildContext(): CC; - } - - // - // Class Interfaces - // ---------------------------------------------------------------------- - - type SFC

= StatelessComponent

; - interface StatelessComponent

{ - (props?: P, context?: any): ReactElement; - propTypes?: ValidationMap

; - contextTypes?: ValidationMap; - defaultProps?: P; - displayName?: string; - } - - interface ComponentClass

{ - new(props?: P, context?: any): Component; - propTypes?: ValidationMap

; - contextTypes?: ValidationMap; - childContextTypes?: ValidationMap; - defaultProps?: P; - displayName?: string; - } - - interface ClassicComponentClass

extends ComponentClass

{ - new(props?: P, context?: any): ClassicComponent; - getDefaultProps?(): P; - } - - /** - * We use an intersection type to infer multiple type parameters from - * a single argument, which is useful for many top-level API defs. - * See https://github.com/Microsoft/TypeScript/issues/7234 for more info. - */ - type ClassType, C extends ComponentClass

> = - C & - (new() => T) & - (new() => { props: P }); - - // - // Component Specs and Lifecycle - // ---------------------------------------------------------------------- - - interface ComponentLifecycle { - componentWillMount?(): void; - componentDidMount?(): void; - componentWillReceiveProps?(nextProps: P, nextContext: any): void; - shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; - componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; - componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; - componentWillUnmount?(): void; - } - - interface Mixin extends ComponentLifecycle { - mixins?: Mixin; - statics?: { - [key: string]: any; - }; - - displayName?: string; - propTypes?: ValidationMap; - contextTypes?: ValidationMap; - childContextTypes?: ValidationMap; - - getDefaultProps?(): P; - getInitialState?(): S; - } - - interface ComponentSpec extends Mixin { - render(): ReactElement; - - [propertyName: string]: any; - } - - // - // Event System - // ---------------------------------------------------------------------- - - interface SyntheticEvent { - bubbles: boolean; - cancelable: boolean; - currentTarget: EventTarget; - defaultPrevented: boolean; - eventPhase: number; - isTrusted: boolean; - nativeEvent: Event; - preventDefault(): void; - stopPropagation(): void; - target: EventTarget; - timeStamp: Date; - type: string; - } - - interface ClipboardEvent extends SyntheticEvent { - clipboardData: DataTransfer; - } - - interface CompositionEvent extends SyntheticEvent { - data: string; - } - - interface DragEvent extends MouseEvent { - dataTransfer: DataTransfer; - } - - interface FocusEvent extends SyntheticEvent { - relatedTarget: EventTarget; - } - - interface FormEvent extends SyntheticEvent { - } - - interface KeyboardEvent extends SyntheticEvent { - altKey: boolean; - charCode: number; - ctrlKey: boolean; - getModifierState(key: string): boolean; - key: string; - keyCode: number; - locale: string; - location: number; - metaKey: boolean; - repeat: boolean; - shiftKey: boolean; - which: number; - } - - interface MouseEvent extends SyntheticEvent { - altKey: boolean; - button: number; - buttons: number; - clientX: number; - clientY: number; - ctrlKey: boolean; - getModifierState(key: string): boolean; - metaKey: boolean; - pageX: number; - pageY: number; - relatedTarget: EventTarget; - screenX: number; - screenY: number; - shiftKey: boolean; - } - - interface TouchEvent extends SyntheticEvent { - altKey: boolean; - changedTouches: TouchList; - ctrlKey: boolean; - getModifierState(key: string): boolean; - metaKey: boolean; - shiftKey: boolean; - targetTouches: TouchList; - touches: TouchList; - } - - interface UIEvent extends SyntheticEvent { - detail: number; - view: AbstractView; - } - - interface WheelEvent extends MouseEvent { - deltaMode: number; - deltaX: number; - deltaY: number; - deltaZ: number; - } - - interface AnimationEvent extends SyntheticEvent { - animationName: string; - pseudoElement: string; - elapsedTime: number; - } - - interface TransitionEvent extends SyntheticEvent { - propertyName: string; - pseudoElement: string; - elapsedTime: number; - } - - // - // Event Handler Types - // ---------------------------------------------------------------------- - - interface EventHandler { - (event: E): void; - } - - type ReactEventHandler = EventHandler; - - type ClipboardEventHandler = EventHandler; - type CompositionEventHandler = EventHandler; - type DragEventHandler = EventHandler; - type FocusEventHandler = EventHandler; - type FormEventHandler = EventHandler; - type KeyboardEventHandler = EventHandler; - type MouseEventHandler = EventHandler; - type TouchEventHandler = EventHandler; - type UIEventHandler = EventHandler; - type WheelEventHandler = EventHandler; - type AnimationEventHandler = EventHandler; - type TransitionEventHandler = EventHandler; - - // - // Props / DOM Attributes - // ---------------------------------------------------------------------- - - /** - * @deprecated. This was used to allow clients to pass `ref` and `key` - * to `createElement`, which is no longer necessary due to intersection - * types. If you need to declare a props object before passing it to - * `createElement` or a factory, use `ClassAttributes`: - * - * ```ts - * var b: Button; - * var props: ButtonProps & ClassAttributes