Skip to content

Commit 2c2c070

Browse files
committed
perf: ts type, close #5044
1 parent 18cc95f commit 2c2c070

File tree

42 files changed

+115
-108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+115
-108
lines changed

components/_util/hooks/useConfigInject.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { RequiredMark } from '../../form/Form';
2-
import type { ComputedRef, UnwrapRef, VNodeChild } from 'vue';
2+
import type { ComputedRef, UnwrapRef } from 'vue';
33
import { computed, inject } from 'vue';
44
import type { ConfigProviderProps, Direction, SizeType } from '../../config-provider';
55
import { defaultConfigProvider } from '../../config-provider';
6+
import type { VueNode } from '../type';
67

78
export default (
89
name: string,
@@ -20,7 +21,7 @@ export default (
2021
requiredMark?: RequiredMark;
2122
}>;
2223
autoInsertSpaceInButton: ComputedRef<boolean>;
23-
renderEmpty?: ComputedRef<(componentName?: string) => VNodeChild | JSX.Element>;
24+
renderEmpty?: ComputedRef<(componentName?: string) => VueNode>;
2425
virtual: ComputedRef<boolean>;
2526
dropdownMatchSelectWidth: ComputedRef<boolean | number>;
2627
getPopupContainer: ComputedRef<ConfigProviderProps['getPopupContainer']>;

components/_util/type.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { App, PropType, VNodeChild, Plugin, Ref } from 'vue';
1+
import type { App, PropType, Plugin, Ref, VNode } from 'vue';
22

33
// https://stackoverflow.com/questions/46176165/ways-to-get-string-literal-type-of-array-values-without-enum-overhead
44
export const tuple = <T extends string[]>(...args: T) => args;
@@ -29,7 +29,8 @@ export interface PropOptions<T = any, D = T> {
2929
validator?(value: unknown): boolean;
3030
}
3131

32-
export type VueNode = VNodeChild | JSX.Element;
32+
declare type VNodeChildAtom = VNode | string | number | boolean | null | undefined | void;
33+
export type VueNode = VNodeChildAtom | VNodeChildAtom[] | JSX.Element;
3334

3435
export const withInstall = <T>(comp: T) => {
3536
const c = comp as any;

components/_util/vue-types/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ PropTypes.extend([
2626
default: undefined,
2727
},
2828
{
29-
name: 'VNodeChild',
29+
name: 'VueNode',
3030
getter: true,
3131
type: null,
3232
},
@@ -39,5 +39,5 @@ export function withUndefined<T extends { default?: any }>(type: T): T {
3939
export default PropTypes as VueTypesInterface & {
4040
readonly looseBool: VueTypeValidableDef<boolean>;
4141
readonly style: VueTypeValidableDef<CSSProperties>;
42-
readonly VNodeChild: VueTypeValidableDef<VueNode>;
42+
readonly VueNode: VueTypeValidableDef<VueNode>;
4343
};

components/alert/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ const alertProps = {
4545
/** Whether Alert can be closed */
4646
closable: PropTypes.looseBool,
4747
/** Close text to show */
48-
closeText: PropTypes.VNodeChild,
48+
closeText: PropTypes.any,
4949
/** Content of Alert */
50-
message: PropTypes.VNodeChild,
50+
message: PropTypes.any,
5151
/** Additional content of Alert */
52-
description: PropTypes.VNodeChild,
52+
description: PropTypes.any,
5353
/** Trigger when animation ending of Alert */
5454
afterClose: PropTypes.func.def(noop),
5555
/** Whether to show icon */
5656
showIcon: PropTypes.looseBool,
5757
prefixCls: PropTypes.string,
5858
banner: PropTypes.looseBool,
59-
icon: PropTypes.VNodeChild,
60-
onClose: PropTypes.VNodeChild,
59+
icon: PropTypes.any,
60+
onClose: PropTypes.any,
6161
};
6262

6363
export type AlertProps = Partial<ExtractPropTypes<typeof alertProps>>;

components/anchor/AnchorLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useInjectAnchor } from './context';
99
const anchorLinkProps = {
1010
prefixCls: PropTypes.string,
1111
href: PropTypes.string.def('#'),
12-
title: PropTypes.VNodeChild,
12+
title: PropTypes.any,
1313
target: PropTypes.string,
1414
};
1515

components/avatar/Avatar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const avatarProps = {
2323
src: PropTypes.string,
2424
/** Srcset of image avatar */
2525
srcset: PropTypes.string,
26-
icon: PropTypes.VNodeChild,
26+
icon: PropTypes.any,
2727
alt: PropTypes.string,
2828
gap: PropTypes.number,
2929
draggable: PropTypes.bool,

components/badge/Badge.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const badgeProps = {
2626
2727
size: PropTypes.oneOf(tuple('default', 'small')).def('default'),
2828
color: PropTypes.string,
29-
text: PropTypes.VNodeChild,
29+
text: PropTypes.any,
3030
offset: PropTypes.arrayOf(PropTypes.oneOfType([String, Number])),
3131
numberStyle: PropTypes.style,
3232
title: PropTypes.string,

components/button/buttonTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const buttonProps = () => ({
3636
ghost: PropTypes.looseBool,
3737
block: PropTypes.looseBool,
3838
danger: PropTypes.looseBool,
39-
icon: PropTypes.VNodeChild,
39+
icon: PropTypes.any,
4040
href: PropTypes.string,
4141
target: PropTypes.string,
4242
title: PropTypes.string,

components/carousel/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export const CarouselProps = {
2020
// style: PropTypes.React.CSSProperties,
2121
prefixCls: PropTypes.string,
2222
accessibility: PropTypes.looseBool,
23-
nextArrow: PropTypes.VNodeChild,
24-
prevArrow: PropTypes.VNodeChild,
23+
nextArrow: PropTypes.any,
24+
prevArrow: PropTypes.any,
2525
pauseOnHover: PropTypes.looseBool,
2626
// className: PropTypes.string,
2727
adaptiveHeight: PropTypes.looseBool,

components/cascader/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ const cascaderProps = {
133133
type: [Boolean, Object] as PropType<boolean | ShowSearchType | undefined>,
134134
default: undefined as PropType<boolean | ShowSearchType | undefined>,
135135
},
136-
notFoundContent: PropTypes.VNodeChild,
136+
notFoundContent: PropTypes.any,
137137
loadData: PropTypes.func,
138138
/** 次级菜单的展开方式,可选 'click' 和 'hover' */
139139
expandTrigger: PropTypes.oneOf(tuple('click', 'hover')),
@@ -147,7 +147,7 @@ const cascaderProps = {
147147
popupVisible: PropTypes.looseBool,
148148
fieldNames: { type: Object as PropType<FieldNamesType> },
149149
autofocus: PropTypes.looseBool,
150-
suffixIcon: PropTypes.VNodeChild,
150+
suffixIcon: PropTypes.any,
151151
showSearchRender: PropTypes.any,
152152
onChange: PropTypes.func,
153153
onPopupVisibleChange: PropTypes.func,

0 commit comments

Comments
 (0)