Skip to content

Commit 042bf61

Browse files
committed
fix: some components miss type, close #4866
1 parent cf9627e commit 042bf61

File tree

15 files changed

+153
-214
lines changed

15 files changed

+153
-214
lines changed

components/date-picker/date-fns.tsx

+16-23
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,22 @@ export type RangePickerProps = BaseRangePickerProps<Date> & ExtraRangePickerProp
1616
const { DatePicker, WeekPicker, MonthPicker, YearPicker, TimePicker, QuarterPicker, RangePicker } =
1717
generatePicker<Date>(dataFnsGenerateConfig);
1818

19-
DatePicker.WeekPicker = WeekPicker;
20-
DatePicker.MonthPicker = MonthPicker;
21-
DatePicker.YearPicker = YearPicker;
22-
DatePicker.RangePicker = RangePicker;
23-
DatePicker.TimePicker = TimePicker;
24-
DatePicker.QuarterPicker = QuarterPicker;
25-
2619
/* istanbul ignore next */
27-
DatePicker.install = function (app: App) {
28-
app.component(DatePicker.name, DatePicker);
29-
app.component(RangePicker.name, RangePicker);
30-
app.component(MonthPicker.name, MonthPicker);
31-
app.component(WeekPicker.name, WeekPicker);
32-
app.component(QuarterPicker.name, QuarterPicker);
33-
return app;
34-
};
35-
3620
export { RangePicker, WeekPicker, MonthPicker, QuarterPicker };
3721

38-
export default DatePicker as typeof DatePicker &
39-
Plugin & {
40-
readonly RangePicker: typeof RangePicker;
41-
readonly MonthPicker: typeof MonthPicker;
42-
readonly WeekPicker: typeof WeekPicker;
43-
readonly QuarterPicker: typeof QuarterPicker;
44-
};
22+
export default Object.assign(DatePicker, {
23+
WeekPicker,
24+
MonthPicker,
25+
YearPicker,
26+
RangePicker,
27+
TimePicker,
28+
QuarterPicker,
29+
install: (app: App) => {
30+
app.component(DatePicker.name, DatePicker);
31+
app.component(RangePicker.name, RangePicker);
32+
app.component(MonthPicker.name, MonthPicker);
33+
app.component(WeekPicker.name, WeekPicker);
34+
app.component(QuarterPicker.name, QuarterPicker);
35+
return app;
36+
},
37+
});

components/date-picker/dayjs.tsx

+16-23
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,22 @@ export type RangePickerProps = BaseRangePickerProps<Dayjs> & ExtraRangePickerPro
1717
const { DatePicker, WeekPicker, MonthPicker, YearPicker, TimePicker, QuarterPicker, RangePicker } =
1818
generatePicker<Dayjs>(dayjsGenerateConfig);
1919

20-
DatePicker.WeekPicker = WeekPicker;
21-
DatePicker.MonthPicker = MonthPicker;
22-
DatePicker.YearPicker = YearPicker;
23-
DatePicker.RangePicker = RangePicker;
24-
DatePicker.TimePicker = TimePicker;
25-
DatePicker.QuarterPicker = QuarterPicker;
26-
2720
/* istanbul ignore next */
28-
DatePicker.install = function (app: App) {
29-
app.component(DatePicker.name, DatePicker);
30-
app.component(RangePicker.name, RangePicker);
31-
app.component(MonthPicker.name, MonthPicker);
32-
app.component(WeekPicker.name, WeekPicker);
33-
app.component(QuarterPicker.name, QuarterPicker);
34-
return app;
35-
};
36-
3721
export { RangePicker, WeekPicker, MonthPicker, QuarterPicker };
3822

39-
export default DatePicker as typeof DatePicker &
40-
Plugin & {
41-
readonly RangePicker: typeof RangePicker;
42-
readonly MonthPicker: typeof MonthPicker;
43-
readonly WeekPicker: typeof WeekPicker;
44-
readonly QuarterPicker: typeof QuarterPicker;
45-
};
23+
export default Object.assign(DatePicker, {
24+
WeekPicker,
25+
MonthPicker,
26+
YearPicker,
27+
RangePicker,
28+
TimePicker,
29+
QuarterPicker,
30+
install: (app: App) => {
31+
app.component(DatePicker.name, DatePicker);
32+
app.component(RangePicker.name, RangePicker);
33+
app.component(MonthPicker.name, MonthPicker);
34+
app.component(WeekPicker.name, WeekPicker);
35+
app.component(QuarterPicker.name, QuarterPicker);
36+
return app;
37+
},
38+
});

components/date-picker/moment.tsx

+16-23
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,22 @@ export type RangePickerProps = BaseRangePickerProps<Moment> & ExtraRangePickerPr
1919
const { DatePicker, WeekPicker, MonthPicker, YearPicker, TimePicker, QuarterPicker, RangePicker } =
2020
generatePicker<Moment>(momentGenerateConfig);
2121

22-
DatePicker.WeekPicker = WeekPicker;
23-
DatePicker.MonthPicker = MonthPicker;
24-
DatePicker.YearPicker = YearPicker;
25-
DatePicker.RangePicker = RangePicker;
26-
DatePicker.TimePicker = TimePicker;
27-
DatePicker.QuarterPicker = QuarterPicker;
28-
2922
/* istanbul ignore next */
30-
DatePicker.install = function (app: App) {
31-
app.component(DatePicker.name, DatePicker);
32-
app.component(RangePicker.name, RangePicker);
33-
app.component(MonthPicker.name, MonthPicker);
34-
app.component(WeekPicker.name, WeekPicker);
35-
app.component(QuarterPicker.name, QuarterPicker);
36-
return app;
37-
};
38-
3923
export { RangePicker, WeekPicker, MonthPicker, QuarterPicker };
4024

41-
export default DatePicker as typeof DatePicker &
42-
Plugin & {
43-
readonly RangePicker: typeof RangePicker;
44-
readonly MonthPicker: typeof MonthPicker;
45-
readonly WeekPicker: typeof WeekPicker;
46-
readonly QuarterPicker: typeof QuarterPicker;
47-
};
25+
export default Object.assign(DatePicker, {
26+
WeekPicker,
27+
MonthPicker,
28+
YearPicker,
29+
RangePicker,
30+
TimePicker,
31+
QuarterPicker,
32+
install: (app: App) => {
33+
app.component(DatePicker.name, DatePicker);
34+
app.component(RangePicker.name, RangePicker);
35+
app.component(MonthPicker.name, MonthPicker);
36+
app.component(WeekPicker.name, WeekPicker);
37+
app.component(QuarterPicker.name, QuarterPicker);
38+
return app;
39+
},
40+
});

components/layout/index.ts

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import type { App, Plugin } from 'vue';
2-
import Layout from './layout';
1+
import type { App } from 'vue';
2+
import Layout, { Header, Footer, Content } from './layout';
33
import Sider from './Sider';
44

55
export type { BasicProps as LayoutProps } from './layout';
66
export type { SiderProps } from './Sider';
77

8-
Layout.Sider = Sider;
9-
108
/* istanbul ignore next */
11-
Layout.install = function (app: App) {
12-
app.component(Layout.name, Layout);
13-
app.component(Layout.Header.name, Layout.Header);
14-
app.component(Layout.Footer.name, Layout.Footer);
15-
app.component(Layout.Sider.name, Layout.Sider);
16-
app.component(Layout.Content.name, Layout.Content);
17-
return app;
18-
};
19-
export const LayoutHeader = Layout.Header;
20-
export const LayoutFooter = Layout.Footer;
21-
export const LayoutSider = Layout.Sider;
22-
export const LayoutContent = Layout.Content;
9+
export const LayoutHeader = Header;
10+
export const LayoutFooter = Footer;
11+
export const LayoutSider = Sider;
12+
export const LayoutContent = Content;
2313

24-
export default Layout as typeof Layout &
25-
Plugin & {
26-
readonly Sider: typeof Sider;
27-
};
14+
export default Object.assign(Layout, {
15+
Header,
16+
Footer,
17+
Content,
18+
Sider,
19+
install: (app: App) => {
20+
app.component(Layout.name, Layout);
21+
app.component(Header.name, Header);
22+
app.component(Footer.name, Footer);
23+
app.component(Sider.name, Sider);
24+
app.component(Content.name, Content);
25+
return app;
26+
},
27+
});

components/layout/layout.tsx

+2-8
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ const Content = generator({
9999
name: 'ALayoutContent',
100100
})(Basic);
101101

102-
Layout.Header = Header;
103-
Layout.Footer = Footer;
104-
Layout.Content = Content;
102+
export { Header, Footer, Content };
105103

106-
export default Layout as typeof Layout & {
107-
readonly Header: typeof Header;
108-
readonly Footer: typeof Footer;
109-
readonly Content: typeof Content;
110-
};
104+
export default Layout;

components/mentions/index.tsx

+14-20
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
import type { App, PropType, Plugin, ExtractPropTypes } from 'vue';
1+
import type { App, PropType, ExtractPropTypes } from 'vue';
22
import { watch, ref, onMounted, defineComponent, nextTick } from 'vue';
33
import classNames from '../_util/classNames';
44
import PropTypes from '../_util/vue-types';
5-
import VcMentions from '../vc-mentions';
5+
import VcMentions, { Option } from '../vc-mentions';
66
import { mentionsProps as baseMentionsProps } from '../vc-mentions/src/mentionsProps';
77
import useConfigInject from '../_util/hooks/useConfigInject';
88
import { flattenChildren, getOptionProps } from '../_util/props-util';
99
import { useInjectFormItemContext } from '../form/FormItemContext';
1010
import omit from '../_util/omit';
1111

12-
const { Option } = VcMentions;
13-
1412
interface MentionsConfig {
1513
prefix?: string | string[];
1614
split?: string;
@@ -85,8 +83,6 @@ const Mentions = defineComponent({
8583
name: 'AMentions',
8684
inheritAttrs: false,
8785
props: mentionsProps,
88-
getMentions,
89-
Option,
9086
emits: ['update:value', 'change', 'focus', 'blur', 'select', 'pressenter'],
9187
slots: ['notFoundContent', 'option'],
9288
setup(props, { slots, emit, attrs, expose }) {
@@ -209,20 +205,18 @@ const Mentions = defineComponent({
209205
},
210206
});
211207

212-
export const MentionsOption = {
208+
/* istanbul ignore next */
209+
export const MentionsOption = defineComponent({
213210
...Option,
214211
name: 'AMentionsOption',
215-
};
216-
217-
/* istanbul ignore next */
218-
Mentions.install = function (app: App) {
219-
app.component(Mentions.name, Mentions);
220-
app.component(MentionsOption.name, MentionsOption);
221-
return app;
222-
};
212+
});
223213

224-
export default Mentions as typeof Mentions &
225-
Plugin & {
226-
getMentions: typeof getMentions;
227-
readonly Option: typeof Option;
228-
};
214+
export default Object.assign(Mentions, {
215+
Option: MentionsOption,
216+
getMentions,
217+
install: (app: App) => {
218+
app.component(Mentions.name, Mentions);
219+
app.component(MentionsOption.name, MentionsOption);
220+
return app;
221+
},
222+
});

components/steps/index.tsx

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { App, ExtractPropTypes, Plugin } from 'vue';
1+
import type { App, ExtractPropTypes } from 'vue';
22
import { computed, defineComponent } from 'vue';
33
import CloseOutlined from '@ant-design/icons-vue/CloseOutlined';
44
import CheckOutlined from '@ant-design/icons-vue/CheckOutlined';
55
import PropTypes, { withUndefined } from '../_util/vue-types';
66
import initDefaultProps from '../_util/props-util/initDefaultProps';
7-
import VcSteps from '../vc-steps';
7+
import VcSteps, { Step as VcStep } from '../vc-steps';
88
import { tuple } from '../_util/type';
99
import useConfigInject from '../_util/hooks/useConfigInject';
1010
import useBreakpoint from '../_util/hooks/useBreakpoint';
@@ -118,19 +118,15 @@ const Steps = defineComponent({
118118
);
119119
};
120120
},
121-
Step: { ...VcSteps.Step, name: 'AStep' },
122121
});
123122

124123
/* istanbul ignore next */
125-
Steps.install = function (app: App) {
126-
app.component(Steps.name, Steps);
127-
app.component(Steps.Step.name, Steps.Step);
128-
return app;
129-
};
130-
131-
export const Step = Steps.Step;
132-
133-
export default Steps as typeof Steps &
134-
Plugin & {
135-
readonly Step: typeof VcSteps.Step;
136-
};
124+
export const Step = defineComponent({ ...VcStep, name: 'AStep' });
125+
export default Object.assign(Steps, {
126+
Step,
127+
install: (app: App) => {
128+
app.component(Steps.name, Steps);
129+
app.component(Step.name, Step);
130+
return app;
131+
},
132+
});

components/time-picker/date-fns.tsx

+9-13
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,14 @@ export interface TimePickerProps extends Omit<PickerTimeProps<Date>, 'picker'> {
1313
popupClassName?: string;
1414
valueFormat?: string;
1515
}
16-
1716
/* istanbul ignore next */
18-
TimePicker.install = function (app: App) {
19-
app.component(TimePicker.name, TimePicker);
20-
app.component(TimeRangePicker.name, TimeRangePicker);
21-
return app;
22-
};
23-
TimePicker.TimeRangePicker = TimeRangePicker;
24-
2517
export { TimePicker, TimeRangePicker };
26-
27-
export default TimePicker as typeof TimePicker &
28-
Plugin & {
29-
readonly TimeRangePicker: typeof TimeRangePicker;
30-
};
18+
export default Object.assign(TimePicker, {
19+
TimePicker,
20+
TimeRangePicker,
21+
install: (app: App) => {
22+
app.component(TimePicker.name, TimePicker);
23+
app.component(TimeRangePicker.name, TimeRangePicker);
24+
return app;
25+
},
26+
});

components/time-picker/dayjs.tsx

+9-12
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@ export interface TimePickerProps extends Omit<PickerTimeProps<Dayjs>, 'picker'>
1616
}
1717

1818
/* istanbul ignore next */
19-
TimePicker.install = function (app: App) {
20-
app.component(TimePicker.name, TimePicker);
21-
app.component(TimeRangePicker.name, TimeRangePicker);
22-
return app;
23-
};
24-
TimePicker.TimeRangePicker = TimeRangePicker;
25-
2619
export { TimePicker, TimeRangePicker };
27-
28-
export default TimePicker as typeof TimePicker &
29-
Plugin & {
30-
readonly TimeRangePicker: typeof TimeRangePicker;
31-
};
20+
export default Object.assign(TimePicker, {
21+
TimePicker,
22+
TimeRangePicker,
23+
install: (app: App) => {
24+
app.component(TimePicker.name, TimePicker);
25+
app.component(TimeRangePicker.name, TimeRangePicker);
26+
return app;
27+
},
28+
});

components/time-picker/moment.tsx

+9-13
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@ export interface TimePickerProps extends Omit<PickerTimeProps<Moment>, 'picker'>
1414
popupClassName?: string;
1515
valueFormat?: string;
1616
}
17-
1817
/* istanbul ignore next */
19-
TimePicker.install = function (app: App) {
20-
app.component(TimePicker.name, TimePicker);
21-
app.component(TimeRangePicker.name, TimeRangePicker);
22-
return app;
23-
};
24-
TimePicker.TimeRangePicker = TimeRangePicker;
25-
2618
export { TimePicker, TimeRangePicker };
27-
28-
export default TimePicker as typeof TimePicker &
29-
Plugin & {
30-
readonly TimeRangePicker: typeof TimeRangePicker;
31-
};
19+
export default Object.assign(TimePicker, {
20+
TimePicker,
21+
TimeRangePicker,
22+
install: (app: App) => {
23+
app.component(TimePicker.name, TimePicker);
24+
app.component(TimeRangePicker.name, TimeRangePicker);
25+
return app;
26+
},
27+
});

0 commit comments

Comments
 (0)