Skip to content

Commit 9499a7f

Browse files
committed
fix: vue 3.3 type error
1 parent 6a1952c commit 9499a7f

File tree

27 files changed

+43
-38
lines changed

27 files changed

+43
-38
lines changed

components/_util/type.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { App, PropType, Plugin, Ref, VNode } from 'vue';
1+
// @ts-ignore
2+
import type { App, PropType, Plugin, Ref, VNode, SlotsType } from 'vue';
23

34
// https://stackoverflow.com/questions/46176165/ways-to-get-string-literal-type-of-array-values-without-enum-overhead
45
export const tuple = <T extends string[]>(...args: T) => args;
@@ -42,3 +43,5 @@ export const withInstall = <T>(comp: T) => {
4243
};
4344

4445
export type MaybeRef<T> = T | Ref<T>;
46+
47+
export type CustomSlotsType<T> = SlotsType<T>;

components/anchor/AnchorLink.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getPropsSlot, initDefaultProps } from '../_util/props-util';
55
import classNames from '../_util/classNames';
66
import useConfigInject from '../_util/hooks/useConfigInject';
77
import { useInjectAnchor } from './context';
8+
import type { CustomSlotsType } from '../_util/type';
89

910
export const anchorLinkProps = () => ({
1011
prefixCls: String,
@@ -19,7 +20,10 @@ export default defineComponent({
1920
compatConfig: { MODE: 3 },
2021
name: 'AAnchorLink',
2122
props: initDefaultProps(anchorLinkProps(), { href: '#' }),
22-
slots: ['title'],
23+
slots: Object as CustomSlotsType<{
24+
title: AnchorLinkProps;
25+
default: any;
26+
}>,
2327
setup(props, { slots }) {
2428
let mergedTitle = null;
2529
const {

components/auto-complete/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Option from './Option';
77
import OptGroup from './OptGroup';
88
import omit from '../_util/omit';
99
import useConfigInject from '../_util/hooks/useConfigInject';
10+
import type { CustomSlotsType } from '../_util/type';
1011

1112
function isSelectOptionOrSelectOptGroup(child: any): boolean {
1213
return child?.type?.isSelectOption || child?.type?.isSelectOptGroup;
@@ -44,7 +45,12 @@ const AutoComplete = defineComponent({
4445
inheritAttrs: false,
4546
props: autoCompleteProps(),
4647
// emits: ['change', 'select', 'focus', 'blur'],
47-
slots: ['option'],
48+
slots: Object as CustomSlotsType<{
49+
option: any;
50+
default: any;
51+
notFoundContent: any;
52+
dataSource: any;
53+
}>,
4854
setup(props, { slots, attrs, expose }) {
4955
warning(
5056
!('dataSource' in slots),

components/avatar/Avatar.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { VueNode } from '../_util/type';
1+
import type { CustomSlotsType, VueNode } from '../_util/type';
22

33
import type { CSSProperties, ExtractPropTypes, PropType } from 'vue';
44
import { computed, defineComponent, nextTick, onMounted, ref, watch } from 'vue';
@@ -41,7 +41,10 @@ const Avatar = defineComponent({
4141
name: 'AAvatar',
4242
inheritAttrs: false,
4343
props: avatarProps(),
44-
slots: ['icon'],
44+
slots: Object as CustomSlotsType<{
45+
icon: AvatarProps;
46+
default: any;
47+
}>,
4548
setup(props, { slots, attrs }) {
4649
const isImgExist = ref(true);
4750
const isMounted = ref(false);

components/badge/Badge.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { isPresetColor } from './utils';
1111
import useConfigInject from '../_util/hooks/useConfigInject';
1212
import isNumeric from '../_util/isNumeric';
1313
import type { PresetStatusColorType } from '../_util/colors';
14+
import type { CustomSlotsType } from '../_util/type';
1415

1516
export const badgeProps = () => ({
1617
/** Number to show in badge */
@@ -39,7 +40,11 @@ export default defineComponent({
3940
Ribbon,
4041
inheritAttrs: false,
4142
props: badgeProps(),
42-
slots: ['text', 'count'],
43+
slots: Object as CustomSlotsType<{
44+
text: BadgeProps;
45+
count: any;
46+
default: any;
47+
}>,
4348
setup(props, { slots, attrs }) {
4449
const { prefixCls, direction } = useConfigInject('badge', props);
4550

components/badge/Ribbon.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { LiteralUnion } from '../_util/type';
1+
import type { CustomSlotsType, LiteralUnion } from '../_util/type';
22
import type { PresetColorType } from '../_util/colors';
33
import { isPresetColor } from './utils';
44
import type { CSSProperties, PropType, ExtractPropTypes } from 'vue';
@@ -20,7 +20,10 @@ export default defineComponent({
2020
name: 'ABadgeRibbon',
2121
inheritAttrs: false,
2222
props: ribbonProps(),
23-
slots: ['text'],
23+
slots: Object as CustomSlotsType<{
24+
text: any;
25+
default: any;
26+
}>,
2427
setup(props, { attrs, slots }) {
2528
const { prefixCls, direction } = useConfigInject('ribbon', props);
2629
const colorInPreset = computed(() => isPresetColor(props.color));

components/breadcrumb/Breadcrumb.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { flattenChildren, getPropsSlot } from '../_util/props-util';
55
import warning from '../_util/warning';
66
import BreadcrumbItem from './BreadcrumbItem';
77
import Menu from '../menu';
8-
import type { VueNode } from '../_util/type';
8+
import type { CustomSlotsType, VueNode } from '../_util/type';
99
import useConfigInject from '../_util/hooks/useConfigInject';
1010

1111
export interface Route {
@@ -55,7 +55,11 @@ export default defineComponent({
5555
compatConfig: { MODE: 3 },
5656
name: 'ABreadcrumb',
5757
props: breadcrumbProps(),
58-
slots: ['separator', 'itemRender'],
58+
slots: Object as CustomSlotsType<{
59+
separator: BreadcrumbProps;
60+
itemRender: { route: Route; params: any; routes: Route[]; paths: string[] };
61+
default: any;
62+
}>,
5963
setup(props, { slots }) {
6064
const { prefixCls, direction } = useConfigInject('breadcrumb', props);
6165

components/button/button.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import LoadingIcon from './LoadingIcon';
1818

1919
import type { ButtonType } from './buttonTypes';
2020
import type { VNode, Ref } from 'vue';
21+
import type { CustomSlotsType } from '../_util/type';
2122

2223
type Loading = boolean | number;
2324

@@ -34,7 +35,10 @@ export default defineComponent({
3435
inheritAttrs: false,
3536
__ANT_BUTTON: true,
3637
props: initDefaultProps(buttonProps(), { type: 'default' }),
37-
slots: ['icon'],
38+
slots: Object as CustomSlotsType<{
39+
icon: any;
40+
default: any;
41+
}>,
3842
// emits: ['click', 'mousedown'],
3943
setup(props, { slots, attrs, emit, expose }) {
4044
const { prefixCls, autoInsertSpaceInButton, direction, size } = useConfigInject('btn', props);

components/vc-drawer/src/DrawerWrapper.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const DrawerWrapper = defineComponent({
2424
autofocus: true,
2525
}),
2626
emits: ['handleClick', 'close'],
27-
slots: ['handler'],
2827
setup(props, { emit, slots }) {
2928
const dom = ref<HTMLElement>(null);
3029

components/vc-dropdown/Dropdown.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export default defineComponent({
3333
mouseLeaveDelay: PropTypes.number.def(0.1),
3434
},
3535
emits: ['visibleChange', 'overlayClick'],
36-
slots: ['overlay'],
3736
setup(props, { slots, emit, expose }) {
3837
const triggerVisible = ref(!!props.visible);
3938
watch(

0 commit comments

Comments
 (0)