diff --git a/.jest.js b/.jest.js index 4457524eea..974124ea28 100644 --- a/.jest.js +++ b/.jest.js @@ -42,4 +42,9 @@ module.exports = { snapshotSerializers: [ 'enzyme-to-json/serializer', ], + globals: { + 'ts-jest': { + tsConfigFile: './tsconfig.test.json', + } + }, }; diff --git a/.jest.node.js b/.jest.node.js index 60a3dd2e98..df22d8c029 100644 --- a/.jest.node.js +++ b/.jest.node.js @@ -18,4 +18,9 @@ module.exports = { snapshotSerializers: [ 'enzyme-to-json/serializer' ], + globals: { + 'ts-jest': { + tsConfigFile: './tsconfig.test.json', + } + }, }; diff --git a/README-zh_CN.md b/README-zh_CN.md index e65bcb7588..2b335ccdcc 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -60,20 +60,7 @@ import 'antd/dist/antd.css'; // or 'antd/dist/antd.less' ## TypeScript -```js -// tsconfig.json -{ - "compilerOptions": { - "moduleResolution": "node", - "jsx": "preserve", - "allowSyntheticDefaultImports": true - } -} -``` - -> 注意: -> - 设置 `allowSyntheticDefaultImports` 避免 `error TS1192: Module 'react' has no default export` 的错误。 -> - 不要使用 @types/antd, antd 已经自带了 TypeScript 定义。 +- 不要使用 @types/antd, antd 已经自带了 TypeScript 定义。 ## 国际化 diff --git a/README.md b/README.md index 55232d868c..7c8ee4b8af 100644 --- a/README.md +++ b/README.md @@ -86,20 +86,7 @@ import 'antd/dist/antd.css'; // or 'antd/dist/antd.less' ### TypeScript -```js -// tsconfig.json -{ - "compilerOptions": { - "moduleResolution": "node", - "jsx": "preserve", - "allowSyntheticDefaultImports": true - } -} -``` - -> Note: -> - set `allowSyntheticDefaultImports` to prevent `error TS1192: Module 'react' has no default export`. -> - Don't use @types/antd, antd provide a built-in ts definition already. +- Don't use @types/antd, antd provide a built-in ts definition already. #### Use [ts-import-plugin](https://github.com/Brooooooklyn/ts-import-plugin) with modularized antd diff --git a/components/_util/callMoment.tsx b/components/_util/callMoment.tsx new file mode 100644 index 0000000000..58933fe9d4 --- /dev/null +++ b/components/_util/callMoment.tsx @@ -0,0 +1,5 @@ +// https://github.com/moment/moment/issues/3650 + +export default function callMoment(moment, ...args) { + return (moment.default || moment)(...args); +} diff --git a/components/affix/index.tsx b/components/affix/index.tsx index 6b0439fab2..0d0864fd52 100644 --- a/components/affix/index.tsx +++ b/components/affix/index.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; import addEventListener from 'rc-util/lib/Dom/addEventListener'; import classNames from 'classnames'; diff --git a/components/alert/index.tsx b/components/alert/index.tsx index 2d9994aaf9..0d6d93f529 100755 --- a/components/alert/index.tsx +++ b/components/alert/index.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import Animate from 'rc-animate'; import Icon from '../icon'; import classNames from 'classnames'; diff --git a/components/anchor/Anchor.tsx b/components/anchor/Anchor.tsx index f25bc21474..3bf7a46849 100644 --- a/components/anchor/Anchor.tsx +++ b/components/anchor/Anchor.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import addEventListener from 'rc-util/lib/Dom/addEventListener'; diff --git a/components/anchor/AnchorLink.tsx b/components/anchor/AnchorLink.tsx index 5d10103ba0..bae40b381e 100644 --- a/components/anchor/AnchorLink.tsx +++ b/components/anchor/AnchorLink.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; diff --git a/components/auto-complete/InputElement.tsx b/components/auto-complete/InputElement.tsx index 9c40304201..0e4e290535 100644 --- a/components/auto-complete/InputElement.tsx +++ b/components/auto-complete/InputElement.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { findDOMNode } from 'react-dom'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; export interface InputElementProps { children: React.ReactElement; @@ -9,10 +9,10 @@ export default class InputElement extends React.Component { - this.ele.focus ? this.ele.focus() : (findDOMNode(this.ele) as HTMLInputElement).focus(); + this.ele.focus ? this.ele.focus() : (ReactDOM.findDOMNode(this.ele) as HTMLInputElement).focus(); } blur = () => { - this.ele.blur ? this.ele.blur() : (findDOMNode(this.ele) as HTMLInputElement).blur(); + this.ele.blur ? this.ele.blur() : (ReactDOM.findDOMNode(this.ele) as HTMLInputElement).blur(); } saveRef = (ele: HTMLInputElement) => { this.ele = ele; diff --git a/components/auto-complete/index.tsx b/components/auto-complete/index.tsx index 3f7cd90681..aec4b1f47b 100755 --- a/components/auto-complete/index.tsx +++ b/components/auto-complete/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import { Option, OptGroup } from 'rc-select'; import classNames from 'classnames'; import Select, { AbstractSelectProps, SelectValue, OptionProps, OptGroupProps } from '../select'; diff --git a/components/avatar/index.tsx b/components/avatar/index.tsx index b04fdd855d..8034b99139 100644 --- a/components/avatar/index.tsx +++ b/components/avatar/index.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import Icon from '../icon'; import classNames from 'classnames'; diff --git a/components/back-top/index.tsx b/components/back-top/index.tsx index e8dbef7830..343ea850d7 100755 --- a/components/back-top/index.tsx +++ b/components/back-top/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import Animate from 'rc-animate'; import addEventListener from 'rc-util/lib/Dom/addEventListener'; import classNames from 'classnames'; diff --git a/components/badge/ScrollNumber.tsx b/components/badge/ScrollNumber.tsx index 479b3c1697..72056959f1 100644 --- a/components/badge/ScrollNumber.tsx +++ b/components/badge/ScrollNumber.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import { createElement, Component } from 'react'; import omit from 'omit.js'; import classNames from 'classnames'; diff --git a/components/badge/index.tsx b/components/badge/index.tsx index ac7cad804e..45a5dabaf5 100644 --- a/components/badge/index.tsx +++ b/components/badge/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import Animate from 'rc-animate'; import ScrollNumber from './ScrollNumber'; diff --git a/components/breadcrumb/Breadcrumb.tsx b/components/breadcrumb/Breadcrumb.tsx index cbf49343c9..3a4a46e1ac 100755 --- a/components/breadcrumb/Breadcrumb.tsx +++ b/components/breadcrumb/Breadcrumb.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import { cloneElement } from 'react'; import warning from '../_util/warning'; diff --git a/components/breadcrumb/BreadcrumbItem.tsx b/components/breadcrumb/BreadcrumbItem.tsx index 7b3a5ec3a4..5e7b613803 100644 --- a/components/breadcrumb/BreadcrumbItem.tsx +++ b/components/breadcrumb/BreadcrumbItem.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; export interface BreadcrumbItemProps { diff --git a/components/button/button-group.tsx b/components/button/button-group.tsx index 8bec71b843..8ed623b710 100644 --- a/components/button/button-group.tsx +++ b/components/button/button-group.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import classNames from 'classnames'; import { ButtonSize } from './button'; diff --git a/components/button/button.tsx b/components/button/button.tsx index 4c87a51fe5..fff28200b7 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import omit from 'omit.js'; diff --git a/components/calendar/Header.tsx b/components/calendar/Header.tsx index 76aa58e25a..ae0ac4d0db 100644 --- a/components/calendar/Header.tsx +++ b/components/calendar/Header.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import moment from 'moment'; +import * as React from 'react'; +import * as moment from 'moment'; import { PREFIX_CLS } from './Constants'; import Select from '../select'; import { Group, Button } from '../radio'; diff --git a/components/calendar/index.tsx b/components/calendar/index.tsx index 9d2d5ee314..9d75f49ece 100644 --- a/components/calendar/index.tsx +++ b/components/calendar/index.tsx @@ -1,10 +1,12 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; -import moment from 'moment'; +import * as moment from 'moment'; import FullCalendar from 'rc-calendar/lib/FullCalendar'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; import { PREFIX_CLS } from './Constants'; import Header from './Header'; +import callMoment from '../_util/callMoment'; + declare const require: Function; export { HeaderProps } from './Header'; @@ -71,7 +73,7 @@ export default class Calendar extends React.Component void; } -export default class Card extends Component { +export default class Card extends React.Component { static Grid: typeof Grid = Grid; static Meta: typeof Meta = Meta; resizeEvent: any; @@ -93,7 +93,7 @@ export default class Card extends Component { } isContainGrid() { let containGrid; - Children.forEach(this.props.children, (element: JSX.Element) => { + React.Children.forEach(this.props.children, (element: JSX.Element) => { if (element && element.type && element.type === Grid) { containGrid = true; } diff --git a/components/carousel/index.tsx b/components/carousel/index.tsx index a10d3360e8..cc385203b5 100644 --- a/components/carousel/index.tsx +++ b/components/carousel/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import debounce from 'lodash.debounce'; // matchMedia polyfill for diff --git a/components/cascader/index.tsx b/components/cascader/index.tsx index a85a606b94..e83374f186 100644 --- a/components/cascader/index.tsx +++ b/components/cascader/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import RcCascader from 'rc-cascader'; import arrayTreeFilter from 'array-tree-filter'; import classNames from 'classnames'; diff --git a/components/checkbox/Checkbox.tsx b/components/checkbox/Checkbox.tsx index 2d52fe583a..4138795ac4 100644 --- a/components/checkbox/Checkbox.tsx +++ b/components/checkbox/Checkbox.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import RcCheckbox from 'rc-checkbox'; diff --git a/components/checkbox/Group.tsx b/components/checkbox/Group.tsx index 3d8fd94924..459bff663c 100644 --- a/components/checkbox/Group.tsx +++ b/components/checkbox/Group.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import shallowEqual from 'shallowequal'; diff --git a/components/collapse/Collapse.tsx b/components/collapse/Collapse.tsx index 644c8eb3c2..5f229bb416 100644 --- a/components/collapse/Collapse.tsx +++ b/components/collapse/Collapse.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import RcCollapse from 'rc-collapse'; import classNames from 'classnames'; import animation from '../_util/openAnimation'; diff --git a/components/date-picker/Calendar.tsx b/components/date-picker/Calendar.tsx index c43ff64b87..d134fe41e5 100644 --- a/components/date-picker/Calendar.tsx +++ b/components/date-picker/Calendar.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import CalendarLocale from 'rc-calendar/lib/locale/zh_CN'; import RcCalendar from 'rc-calendar'; import warning from 'warning'; diff --git a/components/date-picker/RangePicker.tsx b/components/date-picker/RangePicker.tsx index 61077e3765..956a8bc0a6 100644 --- a/components/date-picker/RangePicker.tsx +++ b/components/date-picker/RangePicker.tsx @@ -1,11 +1,12 @@ /* tslint:disable jsx-no-multiline-js */ -import React from 'react'; -import moment from 'moment'; +import * as React from 'react'; +import * as moment from 'moment'; import RangeCalendar from 'rc-calendar/lib/RangeCalendar'; import RcDatePicker from 'rc-calendar/lib/Picker'; import classNames from 'classnames'; import Icon from '../icon'; import warning from '../_util/warning'; +import callMoment from '../_util/callMoment'; function getShowDateFromValue(value: moment.Moment[]): moment.Moment[] | undefined { const [start, end] = value; @@ -60,7 +61,7 @@ export default class RangePicker extends React.Component { const pickerValue = !value || isEmptyArray(value) ? props.defaultPickerValue : value; this.state = { value, - showDate: pickerValueAdapter(pickerValue || moment()), + showDate: pickerValueAdapter(pickerValue || callMoment(moment)), open: props.open, hoverValue: [], }; diff --git a/components/date-picker/WeekPicker.tsx b/components/date-picker/WeekPicker.tsx index 4b895847c1..bd30a455f7 100644 --- a/components/date-picker/WeekPicker.tsx +++ b/components/date-picker/WeekPicker.tsx @@ -1,5 +1,5 @@ -import React, { Component } from 'react'; -import moment from 'moment'; +import * as React from 'react'; +import * as moment from 'moment'; import Calendar from 'rc-calendar'; import RcDatePicker from 'rc-calendar/lib/Picker'; import classNames from 'classnames'; @@ -9,7 +9,7 @@ function formatValue(value: moment.Moment | undefined, format: string): string { return (value && value.format(format)) || ''; } -export default class WeekPicker extends Component { +export default class WeekPicker extends React.Component { static defaultProps = { format: 'YYYY-Wo', allowClear: true, diff --git a/components/date-picker/createPicker.tsx b/components/date-picker/createPicker.tsx index 2f40d42bb5..cf8f654877 100644 --- a/components/date-picker/createPicker.tsx +++ b/components/date-picker/createPicker.tsx @@ -1,11 +1,12 @@ -import React from 'react'; -import moment from 'moment'; +import * as React from 'react'; +import * as moment from 'moment'; import MonthCalendar from 'rc-calendar/lib/MonthCalendar'; import RcDatePicker from 'rc-calendar/lib/Picker'; import classNames from 'classnames'; import omit from 'omit.js'; import Icon from '../icon'; import warning from '../_util/warning'; +import callMoment from '../_util/callMoment'; export interface PickerProps { value?: moment.Moment; @@ -104,7 +105,7 @@ export default function createPicker(TheCalendar): any { disabledTime={disabledTime} locale={locale.lang} timePicker={props.timePicker} - defaultValue={props.defaultPickerValue || moment()} + defaultValue={props.defaultPickerValue || callMoment(moment)} dateInputPlaceholder={placeholder} prefixCls={prefixCls} className={calendarClassName} diff --git a/components/date-picker/index.tsx b/components/date-picker/index.tsx index 8f65d20ba3..ac49ddaac0 100755 --- a/components/date-picker/index.tsx +++ b/components/date-picker/index.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import moment from 'moment'; +import * as React from 'react'; +import * as moment from 'moment'; import RcCalendar from 'rc-calendar'; import MonthCalendar from 'rc-calendar/lib/MonthCalendar'; import createPicker from './createPicker'; diff --git a/components/date-picker/wrapPicker.tsx b/components/date-picker/wrapPicker.tsx index 894755e223..8527816317 100644 --- a/components/date-picker/wrapPicker.tsx +++ b/components/date-picker/wrapPicker.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import TimePickerPanel from 'rc-time-picker/lib/Panel'; import classNames from 'classnames'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; diff --git a/components/divider/index.tsx b/components/divider/index.tsx index 7d139dfe27..3aa7a5e8e3 100644 --- a/components/divider/index.tsx +++ b/components/divider/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import classNames from 'classnames'; export default function Divider({ diff --git a/components/dropdown/dropdown-button.tsx b/components/dropdown/dropdown-button.tsx index b808da2261..d9a5d3e8aa 100644 --- a/components/dropdown/dropdown-button.tsx +++ b/components/dropdown/dropdown-button.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import Button from '../button'; import { ButtonGroupProps } from '../button/button-group'; import Icon from '../icon'; diff --git a/components/dropdown/dropdown.tsx b/components/dropdown/dropdown.tsx index 6cff2a098b..4736434e38 100644 --- a/components/dropdown/dropdown.tsx +++ b/components/dropdown/dropdown.tsx @@ -1,4 +1,4 @@ -import React, { cloneElement } from 'react'; +import * as React from 'react'; import RcDropdown from 'rc-dropdown'; import classNames from 'classnames'; import DropdownButton from './dropdown-button'; @@ -46,7 +46,7 @@ export default class Dropdown extends React.Component { render() { const { children, prefixCls, overlay, trigger, disabled } = this.props; - const dropdownTrigger = cloneElement(children as any, { + const dropdownTrigger = React.cloneElement(children as any, { className: classNames((children as any).props.className, `${prefixCls}-trigger`), disabled, }); @@ -54,7 +54,7 @@ export default class Dropdown extends React.Component { const overlayProps = overlay && (overlay as any).props; const selectable = (overlayProps && 'selectable' in overlayProps) ? overlayProps.selectable : false; - const fixedModeOverlay = cloneElement(overlay as any, { + const fixedModeOverlay = React.cloneElement(overlay as any, { mode: 'vertical', selectable, }); diff --git a/components/form/Form.tsx b/components/form/Form.tsx index 016bca06b4..32e64c5718 100755 --- a/components/form/Form.tsx +++ b/components/form/Form.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import createDOMForm from 'rc-form/lib/createDOMForm'; diff --git a/components/form/FormItem.tsx b/components/form/FormItem.tsx index 6b01885ca3..915fc563a8 100644 --- a/components/form/FormItem.tsx +++ b/components/form/FormItem.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { findDOMNode } from 'react-dom'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import Animate from 'rc-animate'; @@ -230,7 +230,7 @@ export default class FormItem extends React.Component { const controls = document.querySelectorAll(`[id="${id}"]`); if (controls.length !== 1) { e.preventDefault(); - const control = findDOMNode(this).querySelector(`[id="${id}"]`) as HTMLElement; + const control = ReactDOM.findDOMNode(this).querySelector(`[id="${id}"]`) as HTMLElement; if (control && control.focus) { control.focus(); } diff --git a/components/form/__tests__/type.tsx b/components/form/__tests__/type.tsx index d78ae02165..63d2a9608e 100644 --- a/components/form/__tests__/type.tsx +++ b/components/form/__tests__/type.tsx @@ -1,5 +1,5 @@ /* tslint:disable */ -import React from 'react'; +import * as React from 'react'; import Form, { FormComponentProps } from '../Form'; // test Form.create on component without own props diff --git a/components/grid/col.tsx b/components/grid/col.tsx index 93b4acbe9c..2e3d239ed5 100644 --- a/components/grid/col.tsx +++ b/components/grid/col.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; diff --git a/components/grid/row.tsx b/components/grid/row.tsx index 4d782724b7..0094741e31 100644 --- a/components/grid/row.tsx +++ b/components/grid/row.tsx @@ -16,7 +16,7 @@ if (typeof window !== 'undefined') { enquire = require('enquire.js'); } -import React from 'react'; +import * as React from 'react'; import { Children, cloneElement } from 'react'; import classNames from 'classnames'; import PropTypes from 'prop-types'; diff --git a/components/icon/index.tsx b/components/icon/index.tsx index 30e73c80be..84b4e1dbad 100755 --- a/components/icon/index.tsx +++ b/components/icon/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import classNames from 'classnames'; import omit from 'omit.js'; diff --git a/components/input-number/index.tsx b/components/input-number/index.tsx index e29ba71cc8..7b203af53a 100644 --- a/components/input-number/index.tsx +++ b/components/input-number/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import classNames from 'classnames'; import RcInputNumber from 'rc-input-number'; diff --git a/components/input/Group.tsx b/components/input/Group.tsx index 9adfdfaefb..e1346ffe23 100644 --- a/components/input/Group.tsx +++ b/components/input/Group.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import classNames from 'classnames'; export interface GroupProps { diff --git a/components/input/Input.tsx b/components/input/Input.tsx index 63b25a65a5..3ab013ab47 100644 --- a/components/input/Input.tsx +++ b/components/input/Input.tsx @@ -1,4 +1,4 @@ -import React, { Component, cloneElement } from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import omit from 'omit.js'; @@ -45,7 +45,7 @@ export interface InputProps extends AbstractInputProps { autoFocus?: boolean; } -export default class Input extends Component { +export default class Input extends React.Component { static Group: typeof Group; static Search: typeof Search; static TextArea: typeof TextArea; @@ -148,7 +148,7 @@ export default class Input extends Component { > {addonBefore} - {cloneElement(children, { style: null })} + {React.cloneElement(children, { style: null })} {addonAfter} @@ -187,7 +187,7 @@ export default class Input extends Component { style={props.style} > {prefix} - {cloneElement(children, { style: null, className: this.getInputClassName() })} + {React.cloneElement(children, { style: null, className: this.getInputClassName() })} {suffix} ); diff --git a/components/input/Search.tsx b/components/input/Search.tsx index 5f3a01d388..7b2b61fbb6 100644 --- a/components/input/Search.tsx +++ b/components/input/Search.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import classNames from 'classnames'; import Input, { InputProps } from './Input'; import Icon from '../icon'; diff --git a/components/input/TextArea.tsx b/components/input/TextArea.tsx index acdbf2687e..1acd67e758 100644 --- a/components/input/TextArea.tsx +++ b/components/input/TextArea.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import omit from 'omit.js'; import classNames from 'classnames'; import { AbstractInputProps } from './Input'; diff --git a/components/layout/Sider.tsx b/components/layout/Sider.tsx index e5e35d1967..4a1743daba 100644 --- a/components/layout/Sider.tsx +++ b/components/layout/Sider.tsx @@ -14,7 +14,7 @@ if (typeof window !== 'undefined') { window.matchMedia = window.matchMedia || matchMediaPolyfill; } -import React from 'react'; +import * as React from 'react'; import classNames from 'classnames'; import omit from 'omit.js'; import PropTypes from 'prop-types'; diff --git a/components/layout/layout.tsx b/components/layout/layout.tsx index 294bd6d11d..fea46f81b5 100644 --- a/components/layout/layout.tsx +++ b/components/layout/layout.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { SiderProps } from './Sider'; diff --git a/components/list/Item.tsx b/components/list/Item.tsx index c502098c91..e13d00ea31 100644 --- a/components/list/Item.tsx +++ b/components/list/Item.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { Col } from '../grid'; diff --git a/components/list/index.tsx b/components/list/index.tsx index 324a44011e..1ea6180c14 100644 --- a/components/list/index.tsx +++ b/components/list/index.tsx @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; @@ -48,7 +48,7 @@ export interface ListProps { locale?: Object; } -export default class List extends Component { +export default class List extends React.Component { static Item: typeof Item = Item; static childContextTypes = { diff --git a/components/locale-provider/LocaleReceiver.tsx b/components/locale-provider/LocaleReceiver.tsx index ab63e16880..cce8356168 100644 --- a/components/locale-provider/LocaleReceiver.tsx +++ b/components/locale-provider/LocaleReceiver.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; export interface LocaleReceiverProps { diff --git a/components/locale-provider/ar_EG.tsx b/components/locale-provider/ar_EG.tsx index 4b51575950..4b0826ae82 100644 --- a/components/locale-provider/ar_EG.tsx +++ b/components/locale-provider/ar_EG.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('ar'); import Pagination from 'rc-pagination/lib/locale/ar_EG'; diff --git a/components/locale-provider/bg_BG.tsx b/components/locale-provider/bg_BG.tsx index 542b44506e..ead7124e88 100644 --- a/components/locale-provider/bg_BG.tsx +++ b/components/locale-provider/bg_BG.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('bg'); import Pagination from 'rc-pagination/lib/locale/bg_BG'; diff --git a/components/locale-provider/ca_ES.tsx b/components/locale-provider/ca_ES.tsx index f400978abb..ce9cbd8dd2 100644 --- a/components/locale-provider/ca_ES.tsx +++ b/components/locale-provider/ca_ES.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('ca'); import Pagination from 'rc-pagination/lib/locale/ca_ES'; diff --git a/components/locale-provider/cs_CZ.tsx b/components/locale-provider/cs_CZ.tsx index 6a3075aa0d..fe1c8ef27e 100644 --- a/components/locale-provider/cs_CZ.tsx +++ b/components/locale-provider/cs_CZ.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('cs'); import Pagination from 'rc-pagination/lib/locale/cs_CZ'; diff --git a/components/locale-provider/de_DE.tsx b/components/locale-provider/de_DE.tsx index ba5191bcc3..6183c208ff 100644 --- a/components/locale-provider/de_DE.tsx +++ b/components/locale-provider/de_DE.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('de'); import Pagination from 'rc-pagination/lib/locale/de_DE'; diff --git a/components/locale-provider/el_GR.tsx b/components/locale-provider/el_GR.tsx index 02ea7a4c8e..6c8f3fdb14 100644 --- a/components/locale-provider/el_GR.tsx +++ b/components/locale-provider/el_GR.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('el'); import Pagination from 'rc-pagination/lib/locale/el_GR'; diff --git a/components/locale-provider/en_GB.tsx b/components/locale-provider/en_GB.tsx index 026aaaab1c..e1e6d7fe43 100644 --- a/components/locale-provider/en_GB.tsx +++ b/components/locale-provider/en_GB.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('en-gb'); import Pagination from 'rc-pagination/lib/locale/en_GB'; diff --git a/components/locale-provider/en_US.tsx b/components/locale-provider/en_US.tsx index 75b98a0ed2..53c38abb98 100644 --- a/components/locale-provider/en_US.tsx +++ b/components/locale-provider/en_US.tsx @@ -1,5 +1,5 @@ import defaultLocale from './default'; -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('en'); export default defaultLocale; diff --git a/components/locale-provider/et_EE.tsx b/components/locale-provider/et_EE.tsx index c28b450dba..71adebafa3 100644 --- a/components/locale-provider/et_EE.tsx +++ b/components/locale-provider/et_EE.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('et'); import Pagination from 'rc-pagination/lib/locale/et_EE'; diff --git a/components/locale-provider/fa_IR.tsx b/components/locale-provider/fa_IR.tsx index 5e4b2351eb..3078e49bbd 100644 --- a/components/locale-provider/fa_IR.tsx +++ b/components/locale-provider/fa_IR.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('fa'); import Pagination from 'rc-pagination/lib/locale/fa_IR'; diff --git a/components/locale-provider/fi_FI.tsx b/components/locale-provider/fi_FI.tsx index 0352568db2..321c25189b 100644 --- a/components/locale-provider/fi_FI.tsx +++ b/components/locale-provider/fi_FI.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('fi'); import Pagination from 'rc-pagination/lib/locale/fi_FI'; diff --git a/components/locale-provider/fr_BE.tsx b/components/locale-provider/fr_BE.tsx index bc0830f757..7211b62d54 100644 --- a/components/locale-provider/fr_BE.tsx +++ b/components/locale-provider/fr_BE.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('fr'); import Pagination from 'rc-pagination/lib/locale/fr_BE'; diff --git a/components/locale-provider/fr_FR.tsx b/components/locale-provider/fr_FR.tsx index 2698bc0313..b1685d6814 100644 --- a/components/locale-provider/fr_FR.tsx +++ b/components/locale-provider/fr_FR.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('fr'); import Pagination from 'rc-pagination/lib/locale/fr_FR'; diff --git a/components/locale-provider/index.tsx b/components/locale-provider/index.tsx index 052ce36390..138fd243ec 100644 --- a/components/locale-provider/index.tsx +++ b/components/locale-provider/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import { ModalLocale, changeConfirmLocale } from '../modal/locale'; diff --git a/components/locale-provider/is_IS.tsx b/components/locale-provider/is_IS.tsx index 61ea1c604c..c84723bde1 100644 --- a/components/locale-provider/is_IS.tsx +++ b/components/locale-provider/is_IS.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('is'); import Pagination from 'rc-pagination/lib/locale/is_IS'; diff --git a/components/locale-provider/it_IT.tsx b/components/locale-provider/it_IT.tsx index 7b90e4ea4b..376db8a3d0 100644 --- a/components/locale-provider/it_IT.tsx +++ b/components/locale-provider/it_IT.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('it'); import Pagination from 'rc-pagination/lib/locale/it_IT'; diff --git a/components/locale-provider/ja_JP.tsx b/components/locale-provider/ja_JP.tsx index a47d12ea0c..7dc7ca3180 100644 --- a/components/locale-provider/ja_JP.tsx +++ b/components/locale-provider/ja_JP.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('ja'); import Pagination from 'rc-pagination/lib/locale/ja_JP'; diff --git a/components/locale-provider/ko_KR.tsx b/components/locale-provider/ko_KR.tsx index 90b59fe943..1b83816f78 100644 --- a/components/locale-provider/ko_KR.tsx +++ b/components/locale-provider/ko_KR.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('ko'); import Pagination from 'rc-pagination/lib/locale/ko_KR'; diff --git a/components/locale-provider/nb_NO.tsx b/components/locale-provider/nb_NO.tsx index aeec301d40..1c065b5108 100644 --- a/components/locale-provider/nb_NO.tsx +++ b/components/locale-provider/nb_NO.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('nb'); import Pagination from 'rc-pagination/lib/locale/nb_NO'; diff --git a/components/locale-provider/nl_BE.tsx b/components/locale-provider/nl_BE.tsx index 6a4f87e563..a101fc343b 100644 --- a/components/locale-provider/nl_BE.tsx +++ b/components/locale-provider/nl_BE.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('nl-be'); import Pagination from 'rc-pagination/lib/locale/nl_BE'; diff --git a/components/locale-provider/nl_NL.tsx b/components/locale-provider/nl_NL.tsx index c49f862a1c..83ec9fb412 100644 --- a/components/locale-provider/nl_NL.tsx +++ b/components/locale-provider/nl_NL.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('nl'); import Pagination from 'rc-pagination/lib/locale/nl_NL'; diff --git a/components/locale-provider/pl_PL.tsx b/components/locale-provider/pl_PL.tsx index 2bc5e820bc..e4b35c51c4 100644 --- a/components/locale-provider/pl_PL.tsx +++ b/components/locale-provider/pl_PL.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('pl'); import Pagination from 'rc-pagination/lib/locale/pl_PL'; diff --git a/components/locale-provider/pt_BR.tsx b/components/locale-provider/pt_BR.tsx index 690b532462..cb9b0bc057 100644 --- a/components/locale-provider/pt_BR.tsx +++ b/components/locale-provider/pt_BR.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('pt-br'); import Pagination from 'rc-pagination/lib/locale/pt_BR'; diff --git a/components/locale-provider/pt_PT.tsx b/components/locale-provider/pt_PT.tsx index 68851b98eb..65c825ca27 100644 --- a/components/locale-provider/pt_PT.tsx +++ b/components/locale-provider/pt_PT.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('pt'); import Pagination from 'rc-pagination/lib/locale/pt_PT'; diff --git a/components/locale-provider/ru_RU.tsx b/components/locale-provider/ru_RU.tsx index 6c8aa6438d..521dab5256 100644 --- a/components/locale-provider/ru_RU.tsx +++ b/components/locale-provider/ru_RU.tsx @@ -2,7 +2,7 @@ * Created by Andrey Gayvoronsky on 13/04/16. */ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('ru'); import Pagination from 'rc-pagination/lib/locale/ru_RU'; diff --git a/components/locale-provider/sk_SK.tsx b/components/locale-provider/sk_SK.tsx index 2d41336506..a5592107a9 100644 --- a/components/locale-provider/sk_SK.tsx +++ b/components/locale-provider/sk_SK.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('sk'); import Pagination from 'rc-pagination/lib/locale/sk_SK'; diff --git a/components/locale-provider/sr_RS.tsx b/components/locale-provider/sr_RS.tsx index ea95c87d45..a0f25ba718 100644 --- a/components/locale-provider/sr_RS.tsx +++ b/components/locale-provider/sr_RS.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('sr'); import Pagination from 'rc-pagination/lib/locale/sr_RS'; diff --git a/components/locale-provider/sv_SE.tsx b/components/locale-provider/sv_SE.tsx index 145d2945c3..f0b433dccd 100644 --- a/components/locale-provider/sv_SE.tsx +++ b/components/locale-provider/sv_SE.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('sv'); import Pagination from 'rc-pagination/lib/locale/sv_SE'; diff --git a/components/locale-provider/th_TH.tsx b/components/locale-provider/th_TH.tsx index a031385d9e..5991f19f4d 100644 --- a/components/locale-provider/th_TH.tsx +++ b/components/locale-provider/th_TH.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('th'); import Pagination from 'rc-pagination/lib/locale/th_TH'; diff --git a/components/locale-provider/tr_TR.tsx b/components/locale-provider/tr_TR.tsx index 3cb398aa79..cf5b5c295c 100644 --- a/components/locale-provider/tr_TR.tsx +++ b/components/locale-provider/tr_TR.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('tr'); import Pagination from 'rc-pagination/lib/locale/en_US'; diff --git a/components/locale-provider/uk_UA.tsx b/components/locale-provider/uk_UA.tsx index 42edd6eb4d..bdc6878af8 100644 --- a/components/locale-provider/uk_UA.tsx +++ b/components/locale-provider/uk_UA.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('uk'); import Pagination from 'rc-pagination/lib/locale/uk_UA'; diff --git a/components/locale-provider/vi_VN.tsx b/components/locale-provider/vi_VN.tsx index bec4232e09..0b69012d89 100644 --- a/components/locale-provider/vi_VN.tsx +++ b/components/locale-provider/vi_VN.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('vi'); import Pagination from 'rc-pagination/lib/locale/vi_VN'; diff --git a/components/locale-provider/zh_CN.tsx b/components/locale-provider/zh_CN.tsx index dd5166dc38..f912ed7655 100644 --- a/components/locale-provider/zh_CN.tsx +++ b/components/locale-provider/zh_CN.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('zh-cn'); import Pagination from 'rc-pagination/lib/locale/zh_CN'; diff --git a/components/locale-provider/zh_TW.tsx b/components/locale-provider/zh_TW.tsx index 7ab040f869..fc38ee16bf 100644 --- a/components/locale-provider/zh_TW.tsx +++ b/components/locale-provider/zh_TW.tsx @@ -1,4 +1,4 @@ -import moment from 'moment'; +import * as moment from 'moment'; moment.locale('zh-tw'); import Pagination from 'rc-pagination/lib/locale/zh_TW'; diff --git a/components/mention/index.tsx b/components/mention/index.tsx index 846d866e31..216a6ee1ef 100644 --- a/components/mention/index.tsx +++ b/components/mention/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import RcMention, { Nav, toString, toEditorState, getMentions } from 'rc-editor-mention'; import classNames from 'classnames'; import shallowequal from 'shallowequal'; diff --git a/components/menu/MenuItem.tsx b/components/menu/MenuItem.tsx index 2ca63f8c20..e2b0f46727 100644 --- a/components/menu/MenuItem.tsx +++ b/components/menu/MenuItem.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import { Item } from 'rc-menu'; import PropTypes from 'prop-types'; import Tooltip from '../tooltip'; diff --git a/components/menu/SubMenu.tsx b/components/menu/SubMenu.tsx index de042c4611..2c2b7064de 100644 --- a/components/menu/SubMenu.tsx +++ b/components/menu/SubMenu.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import { SubMenu as RcSubMenu } from 'rc-menu'; import classNames from 'classnames'; diff --git a/components/menu/index.tsx b/components/menu/index.tsx index 234eb33a77..9cbaa3e65b 100644 --- a/components/menu/index.tsx +++ b/components/menu/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import RcMenu, { Divider, ItemGroup } from 'rc-menu'; import PropTypes from 'prop-types'; import classNames from 'classnames'; diff --git a/components/message/index.tsx b/components/message/index.tsx index c3843d6e4a..f5bc43b0c4 100755 --- a/components/message/index.tsx +++ b/components/message/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import Notification from 'rc-notification'; import Icon from '../icon'; diff --git a/components/modal/ActionButton.tsx b/components/modal/ActionButton.tsx index 5a8bba2713..acc8543350 100644 --- a/components/modal/ActionButton.tsx +++ b/components/modal/ActionButton.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import Button from '../button'; import { ButtonType } from '../button/button'; diff --git a/components/modal/Modal.tsx b/components/modal/Modal.tsx index 29b3d173bf..6687597a78 100644 --- a/components/modal/Modal.tsx +++ b/components/modal/Modal.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import Dialog from 'rc-dialog'; import PropTypes from 'prop-types'; import addEventListener from 'rc-util/lib/Dom/addEventListener'; diff --git a/components/modal/confirm.tsx b/components/modal/confirm.tsx index 71dd928be3..8901ef557d 100644 --- a/components/modal/confirm.tsx +++ b/components/modal/confirm.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import classNames from 'classnames'; import Icon from '../icon'; import Dialog from './Modal'; diff --git a/components/notification/index.tsx b/components/notification/index.tsx index 3c495e3235..f7d2405388 100755 --- a/components/notification/index.tsx +++ b/components/notification/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import Notification from 'rc-notification'; import Icon from '../icon'; diff --git a/components/pagination/MiniSelect.tsx b/components/pagination/MiniSelect.tsx index 548a445d49..7eb448e337 100644 --- a/components/pagination/MiniSelect.tsx +++ b/components/pagination/MiniSelect.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import Select, { OptionProps } from '../select'; export default class MiniSelect extends React.Component { diff --git a/components/pagination/Pagination.tsx b/components/pagination/Pagination.tsx index 5335ed67fb..770e38162d 100644 --- a/components/pagination/Pagination.tsx +++ b/components/pagination/Pagination.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import RcPagination from 'rc-pagination'; import enUS from 'rc-pagination/lib/locale/en_US'; import classNames from 'classnames'; diff --git a/components/popconfirm/index.tsx b/components/popconfirm/index.tsx index 93f5864146..3a94a691bb 100644 --- a/components/popconfirm/index.tsx +++ b/components/popconfirm/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import Tooltip, { AbstractTooltipProps } from '../tooltip'; import Icon from '../icon'; import Button from '../button'; diff --git a/components/popover/index.tsx b/components/popover/index.tsx index d9d7fa7cb7..d44086b367 100644 --- a/components/popover/index.tsx +++ b/components/popover/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import Tooltip from '../tooltip'; import { AbstractTooltipProps } from '../tooltip'; import warning from '../_util/warning'; diff --git a/components/progress/progress.tsx b/components/progress/progress.tsx index 9fdae39d6b..7611b8d37c 100644 --- a/components/progress/progress.tsx +++ b/components/progress/progress.tsx @@ -1,5 +1,5 @@ import PropTypes from 'prop-types'; -import React from 'react'; +import * as React from 'react'; import Icon from '../icon'; import { Circle } from 'rc-progress'; import classNames from 'classnames'; diff --git a/components/radio/group.tsx b/components/radio/group.tsx index 8f57fdd010..1cba5286e6 100644 --- a/components/radio/group.tsx +++ b/components/radio/group.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import shallowEqual from 'shallowequal'; diff --git a/components/radio/radio.tsx b/components/radio/radio.tsx index 9aa8c1ac99..bac00734c8 100644 --- a/components/radio/radio.tsx +++ b/components/radio/radio.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import RcCheckbox from 'rc-checkbox'; import classNames from 'classnames'; diff --git a/components/radio/radioButton.tsx b/components/radio/radioButton.tsx index efc5ed3666..315082a9a2 100644 --- a/components/radio/radioButton.tsx +++ b/components/radio/radioButton.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import { AbstractCheckboxProps } from '../checkbox/Checkbox'; import Radio from './radio'; diff --git a/components/rate/index.tsx b/components/rate/index.tsx index 331c0b5c8a..db40e2122b 100644 --- a/components/rate/index.tsx +++ b/components/rate/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import RcRate from 'rc-rate'; import Icon from '../icon'; diff --git a/components/select/index.tsx b/components/select/index.tsx index 3572b72dbd..045cbf3113 100755 --- a/components/select/index.tsx +++ b/components/select/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import RcSelect, { Option, OptGroup } from 'rc-select'; import classNames from 'classnames'; diff --git a/components/slider/index.tsx b/components/slider/index.tsx index a591ab1f1b..e8ebda2795 100644 --- a/components/slider/index.tsx +++ b/components/slider/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import RcSlider from 'rc-slider/lib/Slider'; import RcRange from 'rc-slider/lib/Range'; import RcHandle from 'rc-slider/lib/Handle'; diff --git a/components/spin/index.tsx b/components/spin/index.tsx index a540fab6bb..91609e8bbe 100644 --- a/components/spin/index.tsx +++ b/components/spin/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import Animate from 'rc-animate'; diff --git a/components/steps/index.tsx b/components/steps/index.tsx index c65a6d2882..8cf5c8660f 100644 --- a/components/steps/index.tsx +++ b/components/steps/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import RcSteps from 'rc-steps'; diff --git a/components/switch/index.tsx b/components/switch/index.tsx index 2c50350700..cd42ea0c94 100755 --- a/components/switch/index.tsx +++ b/components/switch/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import RcSwitch from 'rc-switch'; import classNames from 'classnames'; diff --git a/components/table/Column.tsx b/components/table/Column.tsx index 72e56cf7c8..a08ef5c70c 100644 --- a/components/table/Column.tsx +++ b/components/table/Column.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; export interface ColumnProps { title?: React.ReactNode; diff --git a/components/table/ColumnGroup.tsx b/components/table/ColumnGroup.tsx index 873f0ace53..6d830b16f4 100644 --- a/components/table/ColumnGroup.tsx +++ b/components/table/ColumnGroup.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; export interface ColumnGroupProps { title?: React.ReactNode; diff --git a/components/table/FilterDropdownMenuWrapper.tsx b/components/table/FilterDropdownMenuWrapper.tsx index 6756eb0655..d52e7f87c0 100644 --- a/components/table/FilterDropdownMenuWrapper.tsx +++ b/components/table/FilterDropdownMenuWrapper.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; export interface FilterDropdownMenuWrapperProps { onClick?: React.MouseEventHandler; diff --git a/components/table/SelectionBox.tsx b/components/table/SelectionBox.tsx index d4d77b8f4b..078596f4fe 100644 --- a/components/table/SelectionBox.tsx +++ b/components/table/SelectionBox.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import Checkbox from '../checkbox'; import Radio from '../radio'; import { Store } from './createStore'; diff --git a/components/table/SelectionCheckboxAll.tsx b/components/table/SelectionCheckboxAll.tsx index 795ff2d54e..8e4b2569a2 100644 --- a/components/table/SelectionCheckboxAll.tsx +++ b/components/table/SelectionCheckboxAll.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import Checkbox from '../checkbox'; import { Store } from './createStore'; import Dropdown from '../dropdown'; diff --git a/components/table/Table.tsx b/components/table/Table.tsx index 92209fd3c9..6852ca7ee2 100755 --- a/components/table/Table.tsx +++ b/components/table/Table.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { findDOMNode } from 'react-dom'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import RcTable from 'rc-table'; import PropTypes from 'prop-types'; import classNames from 'classnames'; @@ -628,7 +628,7 @@ export default class Table extends React.Component, any> { } getPopupContainer = () => { - return findDOMNode(this) as HTMLElement; + return ReactDOM.findDOMNode(this) as HTMLElement; } renderRowSelection(locale) { diff --git a/components/table/filterDropdown.tsx b/components/table/filterDropdown.tsx index e827cba66a..1efd22b5a5 100755 --- a/components/table/filterDropdown.tsx +++ b/components/table/filterDropdown.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import Menu, { SubMenu, Item as MenuItem } from 'rc-menu'; import closest from 'dom-closest'; import classNames from 'classnames'; diff --git a/components/table/util.tsx b/components/table/util.tsx index 586560abaf..7e1b516c72 100644 --- a/components/table/util.tsx +++ b/components/table/util.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; export function flatArray(data: Object[] = [], childrenName = 'children') { const result: Object[] = []; diff --git a/components/tabs/index.tsx b/components/tabs/index.tsx index 6436c9bd17..37dd1705d6 100755 --- a/components/tabs/index.tsx +++ b/components/tabs/index.tsx @@ -1,5 +1,5 @@ -import React, { cloneElement } from 'react'; -import { findDOMNode } from 'react-dom'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import RcTabs, { TabPane } from 'rc-tabs'; import ScrollableInkTabBar from 'rc-tabs/lib/ScrollableInkTabBar'; import TabContent from 'rc-tabs/lib/TabContent'; @@ -78,7 +78,7 @@ export default class Tabs extends React.Component { componentDidMount() { const NO_FLEX = ' no-flex'; - const tabNode = findDOMNode(this); + const tabNode = ReactDOM.findDOMNode(this); if (tabNode && !isFlexSupported() && tabNode.className.indexOf(NO_FLEX) === -1) { tabNode.className += NO_FLEX; } @@ -136,7 +136,7 @@ export default class Tabs extends React.Component { onClick={e => this.removeTab(child.key, e)} /> ) : null; - childrenWithClose.push(cloneElement(child, { + childrenWithClose.push(React.cloneElement(child, { tab: (
{child.props.tab} diff --git a/components/tag/CheckableTag.tsx b/components/tag/CheckableTag.tsx index 6dbc9af55a..1b72b86c2f 100644 --- a/components/tag/CheckableTag.tsx +++ b/components/tag/CheckableTag.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import classNames from 'classnames'; export interface CheckableTagProps { diff --git a/components/tag/index.tsx b/components/tag/index.tsx index 7548c4f6a5..bdede94753 100644 --- a/components/tag/index.tsx +++ b/components/tag/index.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import Animate from 'rc-animate'; import classNames from 'classnames'; import omit from 'omit.js'; diff --git a/components/time-picker/index.tsx b/components/time-picker/index.tsx index f70d3c888e..e6acc5c771 100644 --- a/components/time-picker/index.tsx +++ b/components/time-picker/index.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import moment from 'moment'; +import * as React from 'react'; +import * as moment from 'moment'; import RcTimePicker from 'rc-time-picker/lib/TimePicker'; import classNames from 'classnames'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; diff --git a/components/timeline/Timeline.tsx b/components/timeline/Timeline.tsx index 67a6b5310d..5d9e472c79 100644 --- a/components/timeline/Timeline.tsx +++ b/components/timeline/Timeline.tsx @@ -1,4 +1,4 @@ -import React, { Children } from 'react'; +import * as React from 'react'; import classNames from 'classnames'; import TimelineItem, { TimeLineItemProps } from './TimelineItem'; @@ -23,10 +23,10 @@ export default class Timeline extends React.Component { [`${prefixCls}-pending`]: !!pending, }, className); // Remove falsy items - const falsylessItems = Children.toArray(children).filter(item => !!item); - const items = Children.map(falsylessItems, (ele: React.ReactElement, idx) => + const falsylessItems = React.Children.toArray(children).filter(item => !!item); + const items = React.Children.map(falsylessItems, (ele: React.ReactElement, idx) => React.cloneElement(ele, { - last: idx === (Children.count(falsylessItems) - 1), + last: idx === (React.Children.count(falsylessItems) - 1), }), ); const pendingItem = (!!pending) ? ( diff --git a/components/timeline/TimelineItem.tsx b/components/timeline/TimelineItem.tsx index 6853eafcc2..873a503aa3 100644 --- a/components/timeline/TimelineItem.tsx +++ b/components/timeline/TimelineItem.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import classNames from 'classnames'; export interface TimeLineItemProps { diff --git a/components/tooltip/index.tsx b/components/tooltip/index.tsx index 69daef6a45..17d0c7dc12 100644 --- a/components/tooltip/index.tsx +++ b/components/tooltip/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import { cloneElement } from 'react'; import RcTooltip from 'rc-tooltip'; import classNames from 'classnames'; diff --git a/components/transfer/index.tsx b/components/transfer/index.tsx index 4a56f49fcc..b7ec2e8723 100644 --- a/components/transfer/index.tsx +++ b/components/transfer/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import List, { TransferListProps } from './list'; diff --git a/components/transfer/item.tsx b/components/transfer/item.tsx index 01890a00c5..b2f0dac6c7 100644 --- a/components/transfer/item.tsx +++ b/components/transfer/item.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import classNames from 'classnames'; import PureRenderMixin from 'rc-util/lib/PureRenderMixin'; import Lazyload from 'react-lazy-load'; diff --git a/components/transfer/list.tsx b/components/transfer/list.tsx index e345ebdbc1..1c658f680c 100644 --- a/components/transfer/list.tsx +++ b/components/transfer/list.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { findDOMNode } from 'react-dom'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import classNames from 'classnames'; import Animate from 'rc-animate'; import PureRenderMixin from 'rc-util/lib/PureRenderMixin'; @@ -101,7 +101,7 @@ export default class TransferList extends React.Component { - const listNode = findDOMNode(this).querySelectorAll('.ant-transfer-list-content')[0]; + const listNode = ReactDOM.findDOMNode(this).querySelectorAll('.ant-transfer-list-content')[0]; if (listNode) { triggerEvent(listNode, 'scroll'); } diff --git a/components/transfer/operation.tsx b/components/transfer/operation.tsx index 2e00618d06..913921c165 100644 --- a/components/transfer/operation.tsx +++ b/components/transfer/operation.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import Button from '../button'; function noop() { diff --git a/components/transfer/search.tsx b/components/transfer/search.tsx index 6665c042ec..518d53ad10 100644 --- a/components/transfer/search.tsx +++ b/components/transfer/search.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import Icon from '../icon'; import Input from '../input'; diff --git a/components/tree-select/index.tsx b/components/tree-select/index.tsx index 7f70eea48b..5bb509553d 100644 --- a/components/tree-select/index.tsx +++ b/components/tree-select/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import RcTreeSelect, { TreeNode, SHOW_ALL, SHOW_PARENT, SHOW_CHILD } from 'rc-tree-select'; import classNames from 'classnames'; import { TreeSelectProps } from './interface'; diff --git a/components/tree-select/interface.tsx b/components/tree-select/interface.tsx index bb31cdc79d..bc3820d16c 100644 --- a/components/tree-select/interface.tsx +++ b/components/tree-select/interface.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import { AbstractSelectProps } from '../select'; export interface TreeData { diff --git a/components/tree/index.tsx b/components/tree/index.tsx index e875870cd5..e2433d2458 100644 --- a/components/tree/index.tsx +++ b/components/tree/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import RcTree, { TreeNode } from 'rc-tree'; import animation from '../_util/openAnimation'; diff --git a/components/upload/Dragger.tsx b/components/upload/Dragger.tsx index 1151c206bf..6722ce97ae 100644 --- a/components/upload/Dragger.tsx +++ b/components/upload/Dragger.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import Upload from './Upload'; import { UploadProps } from './interface'; diff --git a/components/upload/Upload.tsx b/components/upload/Upload.tsx index e2b2387e5d..125c59d0ce 100644 --- a/components/upload/Upload.tsx +++ b/components/upload/Upload.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import RcUpload from 'rc-upload'; import classNames from 'classnames'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; diff --git a/components/upload/UploadList.tsx b/components/upload/UploadList.tsx index 5a9b901de9..2ffdf87937 100644 --- a/components/upload/UploadList.tsx +++ b/components/upload/UploadList.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import Animate from 'rc-animate'; import Icon from '../icon'; import Tooltip from '../tooltip'; diff --git a/components/upload/interface.tsx b/components/upload/interface.tsx index dde142a580..70cc6269dd 100755 --- a/components/upload/interface.tsx +++ b/components/upload/interface.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; export type UploadFileStatus = 'error' | 'success' | 'done' | 'uploading' | 'removed'; diff --git a/docs/react/introduce.en-US.md b/docs/react/introduce.en-US.md index ecdf11434d..b8f00318ab 100644 --- a/docs/react/introduce.en-US.md +++ b/docs/react/introduce.en-US.md @@ -112,20 +112,7 @@ import 'antd/dist/antd.css'; // or 'antd/dist/antd.less' ### TypeScript -```js -// tsconfig.json -{ - "compilerOptions": { - "moduleResolution": "node", - "jsx": "preserve", - "allowSyntheticDefaultImports": true - } -} -``` - -> Note: -> - set `allowSyntheticDefaultImports` to prevent `error TS1192: Module 'react' has no default export`. -> - Don't use @types/antd, as antd provides a built-in ts definition already. +- Don't use @types/antd, as antd provides a built-in ts definition already. ## Links diff --git a/docs/react/introduce.zh-CN.md b/docs/react/introduce.zh-CN.md index b7a963d8f0..633648d332 100644 --- a/docs/react/introduce.zh-CN.md +++ b/docs/react/introduce.zh-CN.md @@ -115,20 +115,7 @@ import 'antd/dist/antd.css'; // or 'antd/dist/antd.less' ### TypeScript -```js -// tsconfig.json -{ - "compilerOptions": { - "moduleResolution": "node", - "jsx": "preserve", - "allowSyntheticDefaultImports": true - } -} -``` - -> 注意: -> - 设置 `allowSyntheticDefaultImports` 避免 `error TS1192: Module 'react' has no default export` 的错误。 -> - 不要使用 @types/antd, antd 已经自带了 TypeScript 定义。 +- 不要使用 @types/antd, antd 已经自带了 TypeScript 定义。 ## 链接 diff --git a/package.json b/package.json index e19e8ebb8c..a64822574e 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "rc-animate": "^2.4.1", "rc-calendar": "~9.2.0", "rc-cascader": "~0.12.0", - "rc-checkbox": "~2.0.3", + "rc-checkbox": "~2.1.1", "rc-collapse": "~1.7.5", "rc-dialog": "~7.0.0", "rc-dropdown": "~2.1.0", diff --git a/tsconfig.json b/tsconfig.json index dd6df7d6d7..1a97831a25 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,6 @@ "compilerOptions": { "strictNullChecks": true, "moduleResolution": "node", - "allowSyntheticDefaultImports": true, "experimentalDecorators": true, "jsx": "preserve", "noUnusedParameters": true, diff --git a/tsconfig.test.json b/tsconfig.test.json new file mode 100644 index 0000000000..d22c20b637 --- /dev/null +++ b/tsconfig.test.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "allowSyntheticDefaultImports": true + } +}