fix: vue 3.3 type error
parent
6a1952c469
commit
9499a7fc86
|
@ -1,4 +1,5 @@
|
||||||
import type { App, PropType, Plugin, Ref, VNode } from 'vue';
|
// @ts-ignore
|
||||||
|
import type { App, PropType, Plugin, Ref, VNode, SlotsType } from 'vue';
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/46176165/ways-to-get-string-literal-type-of-array-values-without-enum-overhead
|
// https://stackoverflow.com/questions/46176165/ways-to-get-string-literal-type-of-array-values-without-enum-overhead
|
||||||
export const tuple = <T extends string[]>(...args: T) => args;
|
export const tuple = <T extends string[]>(...args: T) => args;
|
||||||
|
@ -42,3 +43,5 @@ export const withInstall = <T>(comp: T) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type MaybeRef<T> = T | Ref<T>;
|
export type MaybeRef<T> = T | Ref<T>;
|
||||||
|
|
||||||
|
export type CustomSlotsType<T> = SlotsType<T>;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { getPropsSlot, initDefaultProps } from '../_util/props-util';
|
||||||
import classNames from '../_util/classNames';
|
import classNames from '../_util/classNames';
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
import { useInjectAnchor } from './context';
|
import { useInjectAnchor } from './context';
|
||||||
|
import type { CustomSlotsType } from '../_util/type';
|
||||||
|
|
||||||
export const anchorLinkProps = () => ({
|
export const anchorLinkProps = () => ({
|
||||||
prefixCls: String,
|
prefixCls: String,
|
||||||
|
@ -19,7 +20,10 @@ export default defineComponent({
|
||||||
compatConfig: { MODE: 3 },
|
compatConfig: { MODE: 3 },
|
||||||
name: 'AAnchorLink',
|
name: 'AAnchorLink',
|
||||||
props: initDefaultProps(anchorLinkProps(), { href: '#' }),
|
props: initDefaultProps(anchorLinkProps(), { href: '#' }),
|
||||||
slots: ['title'],
|
slots: Object as CustomSlotsType<{
|
||||||
|
title: AnchorLinkProps;
|
||||||
|
default: any;
|
||||||
|
}>,
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
let mergedTitle = null;
|
let mergedTitle = null;
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import Option from './Option';
|
||||||
import OptGroup from './OptGroup';
|
import OptGroup from './OptGroup';
|
||||||
import omit from '../_util/omit';
|
import omit from '../_util/omit';
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
|
import type { CustomSlotsType } from '../_util/type';
|
||||||
|
|
||||||
function isSelectOptionOrSelectOptGroup(child: any): boolean {
|
function isSelectOptionOrSelectOptGroup(child: any): boolean {
|
||||||
return child?.type?.isSelectOption || child?.type?.isSelectOptGroup;
|
return child?.type?.isSelectOption || child?.type?.isSelectOptGroup;
|
||||||
|
@ -44,7 +45,12 @@ const AutoComplete = defineComponent({
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: autoCompleteProps(),
|
props: autoCompleteProps(),
|
||||||
// emits: ['change', 'select', 'focus', 'blur'],
|
// emits: ['change', 'select', 'focus', 'blur'],
|
||||||
slots: ['option'],
|
slots: Object as CustomSlotsType<{
|
||||||
|
option: any;
|
||||||
|
default: any;
|
||||||
|
notFoundContent: any;
|
||||||
|
dataSource: any;
|
||||||
|
}>,
|
||||||
setup(props, { slots, attrs, expose }) {
|
setup(props, { slots, attrs, expose }) {
|
||||||
warning(
|
warning(
|
||||||
!('dataSource' in slots),
|
!('dataSource' in slots),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { VueNode } from '../_util/type';
|
import type { CustomSlotsType, VueNode } from '../_util/type';
|
||||||
|
|
||||||
import type { CSSProperties, ExtractPropTypes, PropType } from 'vue';
|
import type { CSSProperties, ExtractPropTypes, PropType } from 'vue';
|
||||||
import { computed, defineComponent, nextTick, onMounted, ref, watch } from 'vue';
|
import { computed, defineComponent, nextTick, onMounted, ref, watch } from 'vue';
|
||||||
|
@ -41,7 +41,10 @@ const Avatar = defineComponent({
|
||||||
name: 'AAvatar',
|
name: 'AAvatar',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: avatarProps(),
|
props: avatarProps(),
|
||||||
slots: ['icon'],
|
slots: Object as CustomSlotsType<{
|
||||||
|
icon: AvatarProps;
|
||||||
|
default: any;
|
||||||
|
}>,
|
||||||
setup(props, { slots, attrs }) {
|
setup(props, { slots, attrs }) {
|
||||||
const isImgExist = ref(true);
|
const isImgExist = ref(true);
|
||||||
const isMounted = ref(false);
|
const isMounted = ref(false);
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { isPresetColor } from './utils';
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
import isNumeric from '../_util/isNumeric';
|
import isNumeric from '../_util/isNumeric';
|
||||||
import type { PresetStatusColorType } from '../_util/colors';
|
import type { PresetStatusColorType } from '../_util/colors';
|
||||||
|
import type { CustomSlotsType } from '../_util/type';
|
||||||
|
|
||||||
export const badgeProps = () => ({
|
export const badgeProps = () => ({
|
||||||
/** Number to show in badge */
|
/** Number to show in badge */
|
||||||
|
@ -39,7 +40,11 @@ export default defineComponent({
|
||||||
Ribbon,
|
Ribbon,
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: badgeProps(),
|
props: badgeProps(),
|
||||||
slots: ['text', 'count'],
|
slots: Object as CustomSlotsType<{
|
||||||
|
text: BadgeProps;
|
||||||
|
count: any;
|
||||||
|
default: any;
|
||||||
|
}>,
|
||||||
setup(props, { slots, attrs }) {
|
setup(props, { slots, attrs }) {
|
||||||
const { prefixCls, direction } = useConfigInject('badge', props);
|
const { prefixCls, direction } = useConfigInject('badge', props);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { LiteralUnion } from '../_util/type';
|
import type { CustomSlotsType, LiteralUnion } from '../_util/type';
|
||||||
import type { PresetColorType } from '../_util/colors';
|
import type { PresetColorType } from '../_util/colors';
|
||||||
import { isPresetColor } from './utils';
|
import { isPresetColor } from './utils';
|
||||||
import type { CSSProperties, PropType, ExtractPropTypes } from 'vue';
|
import type { CSSProperties, PropType, ExtractPropTypes } from 'vue';
|
||||||
|
@ -20,7 +20,10 @@ export default defineComponent({
|
||||||
name: 'ABadgeRibbon',
|
name: 'ABadgeRibbon',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: ribbonProps(),
|
props: ribbonProps(),
|
||||||
slots: ['text'],
|
slots: Object as CustomSlotsType<{
|
||||||
|
text: any;
|
||||||
|
default: any;
|
||||||
|
}>,
|
||||||
setup(props, { attrs, slots }) {
|
setup(props, { attrs, slots }) {
|
||||||
const { prefixCls, direction } = useConfigInject('ribbon', props);
|
const { prefixCls, direction } = useConfigInject('ribbon', props);
|
||||||
const colorInPreset = computed(() => isPresetColor(props.color));
|
const colorInPreset = computed(() => isPresetColor(props.color));
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { flattenChildren, getPropsSlot } from '../_util/props-util';
|
||||||
import warning from '../_util/warning';
|
import warning from '../_util/warning';
|
||||||
import BreadcrumbItem from './BreadcrumbItem';
|
import BreadcrumbItem from './BreadcrumbItem';
|
||||||
import Menu from '../menu';
|
import Menu from '../menu';
|
||||||
import type { VueNode } from '../_util/type';
|
import type { CustomSlotsType, VueNode } from '../_util/type';
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
|
|
||||||
export interface Route {
|
export interface Route {
|
||||||
|
@ -55,7 +55,11 @@ export default defineComponent({
|
||||||
compatConfig: { MODE: 3 },
|
compatConfig: { MODE: 3 },
|
||||||
name: 'ABreadcrumb',
|
name: 'ABreadcrumb',
|
||||||
props: breadcrumbProps(),
|
props: breadcrumbProps(),
|
||||||
slots: ['separator', 'itemRender'],
|
slots: Object as CustomSlotsType<{
|
||||||
|
separator: BreadcrumbProps;
|
||||||
|
itemRender: { route: Route; params: any; routes: Route[]; paths: string[] };
|
||||||
|
default: any;
|
||||||
|
}>,
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
const { prefixCls, direction } = useConfigInject('breadcrumb', props);
|
const { prefixCls, direction } = useConfigInject('breadcrumb', props);
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import LoadingIcon from './LoadingIcon';
|
||||||
|
|
||||||
import type { ButtonType } from './buttonTypes';
|
import type { ButtonType } from './buttonTypes';
|
||||||
import type { VNode, Ref } from 'vue';
|
import type { VNode, Ref } from 'vue';
|
||||||
|
import type { CustomSlotsType } from '../_util/type';
|
||||||
|
|
||||||
type Loading = boolean | number;
|
type Loading = boolean | number;
|
||||||
|
|
||||||
|
@ -34,7 +35,10 @@ export default defineComponent({
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
__ANT_BUTTON: true,
|
__ANT_BUTTON: true,
|
||||||
props: initDefaultProps(buttonProps(), { type: 'default' }),
|
props: initDefaultProps(buttonProps(), { type: 'default' }),
|
||||||
slots: ['icon'],
|
slots: Object as CustomSlotsType<{
|
||||||
|
icon: any;
|
||||||
|
default: any;
|
||||||
|
}>,
|
||||||
// emits: ['click', 'mousedown'],
|
// emits: ['click', 'mousedown'],
|
||||||
setup(props, { slots, attrs, emit, expose }) {
|
setup(props, { slots, attrs, emit, expose }) {
|
||||||
const { prefixCls, autoInsertSpaceInButton, direction, size } = useConfigInject('btn', props);
|
const { prefixCls, autoInsertSpaceInButton, direction, size } = useConfigInject('btn', props);
|
||||||
|
|
|
@ -24,7 +24,6 @@ const DrawerWrapper = defineComponent({
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
}),
|
}),
|
||||||
emits: ['handleClick', 'close'],
|
emits: ['handleClick', 'close'],
|
||||||
slots: ['handler'],
|
|
||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
const dom = ref<HTMLElement>(null);
|
const dom = ref<HTMLElement>(null);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ export default defineComponent({
|
||||||
mouseLeaveDelay: PropTypes.number.def(0.1),
|
mouseLeaveDelay: PropTypes.number.def(0.1),
|
||||||
},
|
},
|
||||||
emits: ['visibleChange', 'overlayClick'],
|
emits: ['visibleChange', 'overlayClick'],
|
||||||
slots: ['overlay'],
|
|
||||||
setup(props, { slots, emit, expose }) {
|
setup(props, { slots, emit, expose }) {
|
||||||
const triggerVisible = ref(!!props.visible);
|
const triggerVisible = ref(!!props.visible);
|
||||||
watch(
|
watch(
|
||||||
|
|
|
@ -16,7 +16,6 @@ export default defineComponent({
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
slots: ['notFoundContent', 'option'],
|
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
const {
|
const {
|
||||||
activeIndex,
|
activeIndex,
|
||||||
|
|
|
@ -55,7 +55,6 @@ export default defineComponent({
|
||||||
getPopupContainer: Function,
|
getPopupContainer: Function,
|
||||||
direction: String,
|
direction: String,
|
||||||
},
|
},
|
||||||
slots: ['notFoundContent', 'option'],
|
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
const getDropdownPrefix = () => {
|
const getDropdownPrefix = () => {
|
||||||
return `${props.prefixCls}-dropdown`;
|
return `${props.prefixCls}-dropdown`;
|
||||||
|
|
|
@ -37,7 +37,6 @@ export default defineComponent({
|
||||||
name: 'Mentions',
|
name: 'Mentions',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: initDefaultProps(vcMentionsProps, defaultProps),
|
props: initDefaultProps(vcMentionsProps, defaultProps),
|
||||||
slots: ['notFoundContent', 'option'],
|
|
||||||
emits: ['change', 'select', 'search', 'focus', 'blur', 'pressenter'],
|
emits: ['change', 'select', 'search', 'focus', 'blur', 'pressenter'],
|
||||||
setup(props, { emit, attrs, expose, slots }) {
|
setup(props, { emit, attrs, expose, slots }) {
|
||||||
const measure = ref(null);
|
const measure = ref(null);
|
||||||
|
|
|
@ -192,15 +192,6 @@ function Picker<DateType>() {
|
||||||
'secondStep',
|
'secondStep',
|
||||||
'hideDisabledOptions',
|
'hideDisabledOptions',
|
||||||
] as any,
|
] as any,
|
||||||
// slots: [
|
|
||||||
// 'suffixIcon',
|
|
||||||
// 'clearIcon',
|
|
||||||
// 'prevIcon',
|
|
||||||
// 'nextIcon',
|
|
||||||
// 'superPrevIcon',
|
|
||||||
// 'superNextIcon',
|
|
||||||
// 'panelRender',
|
|
||||||
// ],
|
|
||||||
setup(props, { attrs, expose }) {
|
setup(props, { attrs, expose }) {
|
||||||
const inputRef = ref(null);
|
const inputRef = ref(null);
|
||||||
const picker = computed(() => props.picker ?? 'date');
|
const picker = computed(() => props.picker ?? 'date');
|
||||||
|
|
|
@ -37,7 +37,6 @@ const OptionList = defineComponent({
|
||||||
compatConfig: { MODE: 3 },
|
compatConfig: { MODE: 3 },
|
||||||
name: 'OptionList',
|
name: 'OptionList',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
slots: ['option'],
|
|
||||||
setup(_, { expose, slots }) {
|
setup(_, { expose, slots }) {
|
||||||
const baseProps = useBaseProps();
|
const baseProps = useBaseProps();
|
||||||
const props = useSelectProps();
|
const props = useSelectProps();
|
||||||
|
|
|
@ -43,7 +43,6 @@ export default function createSlider(Component) {
|
||||||
name: 'CreateSlider',
|
name: 'CreateSlider',
|
||||||
mixins: [BaseMixin, Component],
|
mixins: [BaseMixin, Component],
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
slots: ['mark'],
|
|
||||||
props: initDefaultProps(propTypes, {
|
props: initDefaultProps(propTypes, {
|
||||||
prefixCls: 'rc-slider',
|
prefixCls: 'rc-slider',
|
||||||
min: 0,
|
min: 0,
|
||||||
|
|
|
@ -36,7 +36,6 @@ export default defineComponent({
|
||||||
compatConfig: { MODE: 3 },
|
compatConfig: { MODE: 3 },
|
||||||
name: 'Step',
|
name: 'Step',
|
||||||
props: VcStepProps(),
|
props: VcStepProps(),
|
||||||
slots: ['title', 'subTitle', 'description', 'tailContent', 'stepIcon', 'progressDot'],
|
|
||||||
emits: ['click', 'stepClick'],
|
emits: ['click', 'stepClick'],
|
||||||
setup(props, { slots, emit }) {
|
setup(props, { slots, emit }) {
|
||||||
const onItemClick: EventHandler = e => {
|
const onItemClick: EventHandler = e => {
|
||||||
|
|
|
@ -41,7 +41,6 @@ export default defineComponent({
|
||||||
}).loose,
|
}).loose,
|
||||||
stepIcon: Function,
|
stepIcon: Function,
|
||||||
},
|
},
|
||||||
slots: ['stepIcon', 'progressDot'],
|
|
||||||
emits: ['change'],
|
emits: ['change'],
|
||||||
setup(props, { slots, emit }) {
|
setup(props, { slots, emit }) {
|
||||||
const onStepClick = next => {
|
const onStepClick = next => {
|
||||||
|
|
|
@ -32,7 +32,6 @@ export default defineComponent<BodyProps<any>>({
|
||||||
'rowExpandable',
|
'rowExpandable',
|
||||||
'childrenColumnName',
|
'childrenColumnName',
|
||||||
] as any,
|
] as any,
|
||||||
slots: ['emptyNode'],
|
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
const resizeContext = useInjectResize();
|
const resizeContext = useInjectResize();
|
||||||
const tableContext = useInjectTable();
|
const tableContext = useInjectTable();
|
||||||
|
|
|
@ -108,7 +108,6 @@ export default defineComponent<CellProps>({
|
||||||
'cellType',
|
'cellType',
|
||||||
'transformCellText',
|
'transformCellText',
|
||||||
] as any,
|
] as any,
|
||||||
slots: ['appendNode'],
|
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
const contextSlots = useInjectSlots();
|
const contextSlots = useInjectSlots();
|
||||||
const { onHover, startRow, endRow } = useInjectHover();
|
const { onHover, startRow, endRow } = useInjectHover();
|
||||||
|
|
|
@ -192,7 +192,6 @@ export default defineComponent<TableProps<DefaultRecordType>>({
|
||||||
'onUpdateInternalRefs',
|
'onUpdateInternalRefs',
|
||||||
'transformCellText',
|
'transformCellText',
|
||||||
] as any,
|
] as any,
|
||||||
slots: ['title', 'footer', 'summary', 'emptyText'],
|
|
||||||
emits: ['expand', 'expandedRowsChange', 'updateInternalRefs', 'update:expandedRowKeys'],
|
emits: ['expand', 'expandedRowsChange', 'updateInternalRefs', 'update:expandedRowKeys'],
|
||||||
setup(props, { attrs, slots, emit }) {
|
setup(props, { attrs, slots, emit }) {
|
||||||
const mergedData = computed(() => props.data || EMPTY_DATA);
|
const mergedData = computed(() => props.data || EMPTY_DATA);
|
||||||
|
|
|
@ -14,7 +14,6 @@ export default defineComponent({
|
||||||
compatConfig: { MODE: 3 },
|
compatConfig: { MODE: 3 },
|
||||||
name: 'Content',
|
name: 'Content',
|
||||||
props: tooltipContentProps,
|
props: tooltipContentProps,
|
||||||
slots: ['overlay'],
|
|
||||||
setup(props: TooltipContentProps, { slots }) {
|
setup(props: TooltipContentProps, { slots }) {
|
||||||
return () => (
|
return () => (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -37,7 +37,6 @@ export default defineComponent({
|
||||||
onVisibleChange: Function,
|
onVisibleChange: Function,
|
||||||
onPopupAlign: Function,
|
onPopupAlign: Function,
|
||||||
},
|
},
|
||||||
slots: ['arrowContent', 'overlay'],
|
|
||||||
setup(props, { slots, attrs, expose }) {
|
setup(props, { slots, attrs, expose }) {
|
||||||
const triggerDOM = ref();
|
const triggerDOM = ref();
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ export default defineComponent({
|
||||||
compatConfig: { MODE: 3 },
|
compatConfig: { MODE: 3 },
|
||||||
name: 'OptionList',
|
name: 'OptionList',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
slots: ['notFoundContent', 'menuItemSelectedIcon'],
|
|
||||||
setup(_, { slots, expose }) {
|
setup(_, { slots, expose }) {
|
||||||
const baseProps = useBaseProps();
|
const baseProps = useBaseProps();
|
||||||
const legacyContext = useInjectLegacySelectContext();
|
const legacyContext = useInjectLegacySelectContext();
|
||||||
|
|
|
@ -29,7 +29,6 @@ export default defineComponent({
|
||||||
motionType: String,
|
motionType: String,
|
||||||
// treeNodeRequiredProps: { type: Object as PropType<TreeNodeRequiredProps> },
|
// treeNodeRequiredProps: { type: Object as PropType<TreeNodeRequiredProps> },
|
||||||
},
|
},
|
||||||
slots: ['title', 'icon', 'switcherIcon', 'checkable'],
|
|
||||||
setup(props, { attrs, slots }) {
|
setup(props, { attrs, slots }) {
|
||||||
const visible = ref(true);
|
const visible = ref(true);
|
||||||
const context = useInjectTreeContext();
|
const context = useInjectTreeContext();
|
||||||
|
|
|
@ -55,7 +55,6 @@ export default defineComponent({
|
||||||
compatConfig: { MODE: 3 },
|
compatConfig: { MODE: 3 },
|
||||||
name: 'Tree',
|
name: 'Tree',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
slots: ['checkable', 'title', 'icon', 'titleRender'],
|
|
||||||
props: initDefaultProps(treeProps(), {
|
props: initDefaultProps(treeProps(), {
|
||||||
prefixCls: 'vc-tree',
|
prefixCls: 'vc-tree',
|
||||||
showLine: false,
|
showLine: false,
|
||||||
|
|
|
@ -29,7 +29,6 @@ export default defineComponent({
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: treeNodeProps,
|
props: treeNodeProps,
|
||||||
isTreeNode: 1,
|
isTreeNode: 1,
|
||||||
slots: ['title', 'icon', 'switcherIcon'],
|
|
||||||
setup(props, { attrs, slots, expose }) {
|
setup(props, { attrs, slots, expose }) {
|
||||||
warning(
|
warning(
|
||||||
!('slots' in props.data),
|
!('slots' in props.data),
|
||||||
|
|
Loading…
Reference in New Issue