From 0afdbe4d4aaeb25d39dbd882e3d9ba65b51386a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Sun, 24 Jan 2021 23:24:06 +0800 Subject: [PATCH] fix: exporting common types (#28963) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * exporting common types * no use importype * fix test * try fix test * Update components/index.tsx Co-authored-by: 偏右 * remove typo * fix test Co-authored-by: 偏右 --- .eslintignore | 3 +- components/calendar/index.tsx | 3 +- components/config-provider/index.tsx | 7 ++- components/grid/index.tsx | 1 + components/index.tsx | 68 ++++++++++++++++++++++++++++ components/menu/index.tsx | 10 ++-- components/statistic/index.tsx | 4 +- package.json | 1 - tests/setup.js | 5 ++ 9 files changed, 93 insertions(+), 9 deletions(-) diff --git a/.eslintignore b/.eslintignore index b4e2cb7be0..405a906945 100644 --- a/.eslintignore +++ b/.eslintignore @@ -28,4 +28,5 @@ coverage **/*.d.ts # Scripts scripts/previewEditor/**/* -jest-stare \ No newline at end of file +jest-stare +**/*.md \ No newline at end of file diff --git a/components/calendar/index.tsx b/components/calendar/index.tsx index 0dc2d87852..c15913b576 100644 --- a/components/calendar/index.tsx +++ b/components/calendar/index.tsx @@ -1,7 +1,8 @@ import { Moment } from 'moment'; import momentGenerateConfig from 'rc-picker/lib/generate/moment'; -import generateCalendar from './generateCalendar'; +import generateCalendar, { CalendarProps } from './generateCalendar'; const Calendar = generateCalendar(momentGenerateConfig); +export { CalendarProps }; export default Calendar; diff --git a/components/config-provider/index.tsx b/components/config-provider/index.tsx index 5b0512d521..3d68e3f5b4 100644 --- a/components/config-provider/index.tsx +++ b/components/config-provider/index.tsx @@ -4,7 +4,7 @@ import { FormProvider as RcFormProvider } from 'rc-field-form'; import { ValidateMessages } from 'rc-field-form/lib/interface'; import useMemo from 'rc-util/lib/hooks/useMemo'; import { RenderEmptyHandler } from './renderEmpty'; -import LocaleProvider, { Locale, ANT_MARK } from '../locale-provider'; +import LocaleProvider, { ANT_MARK, Locale } from '../locale-provider'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; import { ConfigConsumer, @@ -13,7 +13,7 @@ import { DirectionType, ConfigConsumerProps, } from './context'; -import { SizeType, SizeContextProvider } from './SizeContext'; +import SizeContext, { SizeContextProvider, SizeType } from './SizeContext'; import message from '../message'; import notification from '../notification'; import { RequiredMark } from '../form/Form'; @@ -184,6 +184,7 @@ const ProviderChildren: React.FC = props => { const ConfigProvider: React.FC & { ConfigContext: typeof ConfigContext; + SizeContext: typeof SizeContext; } = props => { React.useEffect(() => { if (props.direction) { @@ -215,4 +216,6 @@ const ConfigProvider: React.FC & { /** @private internal usage. do not use in your production */ ConfigProvider.ConfigContext = ConfigContext; +ConfigProvider.SizeContext = SizeContext; + export default ConfigProvider; diff --git a/components/grid/index.tsx b/components/grid/index.tsx index f2c4e59c74..80aee3f9be 100644 --- a/components/grid/index.tsx +++ b/components/grid/index.tsx @@ -3,6 +3,7 @@ import Col from './col'; import useBreakpoint from './hooks/useBreakpoint'; export { RowProps } from './row'; + export { ColProps, ColSize } from './col'; export { Row, Col }; diff --git a/components/index.tsx b/components/index.tsx index aa09136621..3a47dcf32e 100644 --- a/components/index.tsx +++ b/components/index.tsx @@ -16,132 +16,200 @@ if ( } /* @remove-on-es-build-end */ +export type { AffixProps } from './affix'; export { default as Affix } from './affix'; +export type { AnchorProps, AnchorLinkProps } from './anchor'; export { default as Anchor } from './anchor'; +export type { AutoCompleteProps } from './auto-complete'; export { default as AutoComplete } from './auto-complete'; +export type { AlertProps } from './alert'; export { default as Alert } from './alert'; +export type { AvatarProps } from './avatar'; export { default as Avatar } from './avatar'; +export type { BackTopProps } from './back-top'; export { default as BackTop } from './back-top'; +export type { BadgeProps } from './badge'; export { default as Badge } from './badge'; +export type { BreadcrumbProps, BreadcrumbItemProps } from './breadcrumb'; export { default as Breadcrumb } from './breadcrumb'; +export type { ButtonProps } from './button'; export { default as Button } from './button'; +export type { CalendarProps } from './calendar'; export { default as Calendar } from './calendar'; +export type { CardProps } from './card'; export { default as Card } from './card'; +export type { CollapseProps, CollapsePanelProps } from './collapse'; export { default as Collapse } from './collapse'; +export type { CarouselProps } from './carousel'; export { default as Carousel } from './carousel'; +export type { CascaderProps } from './cascader'; export { default as Cascader } from './cascader'; +export type { CheckboxProps, CheckboxOptionType } from './checkbox'; export { default as Checkbox } from './checkbox'; +export type { ColProps } from './col'; export { default as Col } from './col'; +export type { CommentProps } from './comment'; export { default as Comment } from './comment'; export { default as ConfigProvider } from './config-provider'; +export type { DatePickerProps } from './date-picker'; export { default as DatePicker } from './date-picker'; +export type { DescriptionsProps } from './descriptions'; export { default as Descriptions } from './descriptions'; +export type { DividerProps } from './divider'; export { default as Divider } from './divider'; +export type { DropDownProps } from './dropdown'; export { default as Dropdown } from './dropdown'; +export type { DrawerProps } from './drawer'; export { default as Drawer } from './drawer'; +export type { EmptyProps } from './empty'; export { default as Empty } from './empty'; +export type { FormInstance, FormProps, FormItemProps } from './form'; export { default as Form } from './form'; export { default as Grid } from './grid'; +export type { InputProps } from './input'; export { default as Input } from './input'; +export type { ImageProps } from './image'; export { default as Image } from './image'; +export type { InputNumberProps } from './input-number'; export { default as InputNumber } from './input-number'; +export type { LayoutProps } from './layout'; export { default as Layout } from './layout'; +export type { ListProps } from './list'; export { default as List } from './list'; +export type { ArgsProps as MessageArgsProps } from './message'; export { default as message } from './message'; +export type { MenuProps, MenuTheme, SubMenuProps, MenuItemProps } from './menu'; export { default as Menu } from './menu'; +export type { MentionProps } from './mentions'; export { default as Mentions } from './mentions'; +export type { ModalProps, ModalFuncProps } from './modal'; export { default as Modal } from './modal'; +export type { StatisticProps } from './statistic'; export { default as Statistic } from './statistic'; export { default as notification } from './notification'; +export type { PageHeaderProps } from './page-header'; export { default as PageHeader } from './page-header'; +export type { PaginationProps } from './pagination'; export { default as Pagination } from './pagination'; +export type { PopconfirmProps } from './popconfirm'; export { default as Popconfirm } from './popconfirm'; +export type { PopoverProps } from './popover'; export { default as Popover } from './popover'; +export type { ProgressProps } from './progress'; export { default as Progress } from './progress'; +export type { RadioProps, RadioChangeEvent, RadioGroupProps } from './radio'; export { default as Radio } from './radio'; +export type { RateProps } from './rate'; export { default as Rate } from './rate'; +export type { ResultProps } from './result'; export { default as Result } from './result'; +export type { RowProps } from './row'; export { default as Row } from './row'; +export type { SelectProps } from './select'; export { default as Select } from './select'; +export type { SkeletonProps } from './skeleton'; export { default as Skeleton } from './skeleton'; +export type { SliderSingleProps } from './slider'; export { default as Slider } from './slider'; +export type { SpaceProps } from './space'; export { default as Space } from './space'; +export type { SpinProps } from './spin'; export { default as Spin } from './spin'; +export type { StepProps, StepsProps } from './steps'; export { default as Steps } from './steps'; +export type { SwitchProps } from './switch'; export { default as Switch } from './switch'; +export type { + TableProps, + TablePaginationConfig, + ColumnGroupType as TableColumnGroupType, + ColumnType as TableColumnType, + ColumnProps as TableColumnProps, +} from './table'; export { default as Table } from './table'; +export type { TransferProps } from './transfer'; export { default as Transfer } from './transfer'; +export type { TreeProps, AntTreeNodeProps as TreeNodeProps } from './tree'; export { default as Tree } from './tree'; +export type { TreeSelectProps } from './tree-select'; export { default as TreeSelect } from './tree-select'; +export type { TabsProps, TabPaneProps } from './tabs'; export { default as Tabs } from './tabs'; +export type { TagProps, TagType } from './tag'; export { default as Tag } from './tag'; +export type { TimePickerProps, TimeRangePickerProps } from './time-picker'; export { default as TimePicker } from './time-picker'; +export type { TimelineProps, TimelineItemProps } from './timeline'; export { default as Timeline } from './timeline'; +export type { TooltipProps } from './tooltip'; export { default as Tooltip } from './tooltip'; +export type { TypographyProps } from './typography'; export { default as Typography } from './typography'; +export type { UploadProps } from './upload'; + export { default as Upload } from './upload'; export { default as version } from './version'; diff --git a/components/menu/index.tsx b/components/menu/index.tsx index 44478edf6e..8caf792597 100644 --- a/components/menu/index.tsx +++ b/components/menu/index.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; import RcMenu, { Divider, ItemGroup, MenuProps as RcMenuProps } from 'rc-menu'; import classNames from 'classnames'; -import SubMenu from './SubMenu'; -import Item from './MenuItem'; +import SubMenu, { SubMenuProps } from './SubMenu'; +import Item, { MenuItemProps } from './MenuItem'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; import devWarning from '../_util/devWarning'; import { SiderContext, SiderContextProps } from '../layout/Sider'; @@ -99,7 +99,7 @@ class InternalMenu extends React.Component { } // We should keep this as ref-able -export default class Menu extends React.Component { +class Menu extends React.Component { static Divider = Divider; static Item = Item; @@ -116,3 +116,7 @@ export default class Menu extends React.Component { ); } } + +export { MenuTheme, SubMenuProps, MenuItemProps }; + +export default Menu; diff --git a/components/statistic/index.tsx b/components/statistic/index.tsx index 3f60608f64..fb053825c3 100644 --- a/components/statistic/index.tsx +++ b/components/statistic/index.tsx @@ -1,6 +1,8 @@ -import Statistic from './Statistic'; +import Statistic, { StatisticProps } from './Statistic'; import Countdown from './Countdown'; Statistic.Countdown = Countdown; +export { StatisticProps }; + export default Statistic; diff --git a/package.json b/package.json index 7ea215aed9..80c348b9dd 100644 --- a/package.json +++ b/package.json @@ -178,7 +178,6 @@ "antd-theme-generator": "^1.2.3", "argos-cli": "^0.3.0", "array-move": "^3.0.0", - "babel-eslint": "^10.0.1", "babel-plugin-add-react-displayname": "^0.0.5", "bisheng": "^3.0.0", "bisheng-plugin-description": "^0.1.4", diff --git a/tests/setup.js b/tests/setup.js index a68518eaf7..aec592ee0f 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -3,6 +3,11 @@ const React = require('react'); // eslint-disable-next-line no-console console.log('Current React Version:', React.version); +// jest.mock('react', () => ({ +// ...jest.requireActual('react'), +// useLayoutEffect: jest.requireActual('react').useEffect, +// })); + /* eslint-disable global-require */ if (typeof window !== 'undefined') { global.window.resizeTo = (width, height) => {