Skip to content

Commit f3063e0

Browse files
authored
fix: update components type (#3165)
1 parent 4ab7a68 commit f3063e0

File tree

9 files changed

+18
-23
lines changed

9 files changed

+18
-23
lines changed

components/auto-complete/index.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import warning from '../_util/warning';
1010

1111
const { Option, OptGroup } = Select;
1212

13-
function isSelectOptionOrSelectOptGroup(child: any): Boolean {
14-
return child && child.type && (child.type.isSelectOption || child.type.isSelectOptGroup);
13+
function isSelectOptionOrSelectOptGroup(child: any): boolean {
14+
return child?.type?.isSelectOption || child?.type?.isSelectOptGroup;
1515
}
1616

1717
const AutoCompleteProps = {
@@ -83,12 +83,12 @@ const AutoComplete = defineComponent({
8383

8484
render() {
8585
const { size, prefixCls: customizePrefixCls, dataSource } = this;
86-
let optionChildren: any;
86+
let optionChildren: VNode[];
8787
const { getPrefixCls } = this.configProvider;
8888
const prefixCls = getPrefixCls('select', customizePrefixCls);
89-
const { class: className } = this.$attrs as any;
89+
const { class: className } = this.$attrs;
9090
const cls = {
91-
[className]: !!className,
91+
[className as string]: !!className,
9292
[`${prefixCls}-lg`]: size === 'large',
9393
[`${prefixCls}-sm`]: size === 'small',
9494
[`${prefixCls}-show-search`]: true,

components/badge/ScrollNumber.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,7 @@ export default defineComponent({
161161
},
162162

163163
render() {
164-
const {
165-
prefixCls: customizePrefixCls,
166-
title,
167-
component: Tag = 'sup' as any,
168-
displayComponent,
169-
} = this;
164+
const { prefixCls: customizePrefixCls, title, component: Tag = 'sup', displayComponent } = this;
170165
const getPrefixCls = this.configProvider.getPrefixCls;
171166
const prefixCls = getPrefixCls('scroll-number', customizePrefixCls);
172167
const { class: className, style = {} } = this.$attrs as {

components/cascader/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function defaultSortFilteredOption(
161161
inputValue: string,
162162
names: FilledFieldNamesType,
163163
) {
164-
function callback(elem) {
164+
function callback(elem: CascaderOptionType) {
165165
return elem[names.label].indexOf(inputValue) > -1;
166166
}
167167

@@ -327,7 +327,7 @@ const Cascader = defineComponent({
327327
},
328328

329329
handleInputChange(e: Event) {
330-
const inputValue = (e.target as any).value;
330+
const inputValue = (e.target as HTMLInputElement).value;
331331
this.setState({ inputValue });
332332
this.$emit('search', inputValue);
333333
},

components/collapse/Collapse.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ export default defineComponent({
6060
const { prefixCls: customizePrefixCls, bordered, expandIconPosition } = this;
6161
const getPrefixCls = this.configProvider.getPrefixCls;
6262
const prefixCls = getPrefixCls('collapse', customizePrefixCls);
63-
const { class: className, ...restAttrs } = this.$attrs as any;
63+
const { class: className, ...restAttrs } = this.$attrs;
6464
const collapseClassName = {
65-
[className]: className,
65+
[className as string]: className,
6666
[`${prefixCls}-borderless`]: !bordered,
6767
[`${prefixCls}-icon-position-${expandIconPosition}`]: true,
6868
};

components/collapse/CollapsePanel.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ export default defineComponent({
3131
const { prefixCls: customizePrefixCls, showArrow = true } = this;
3232
const getPrefixCls = this.configProvider.getPrefixCls;
3333
const prefixCls = getPrefixCls('collapse', customizePrefixCls);
34-
const { class: className, ...restAttrs } = this.$attrs as any;
34+
const { class: className, ...restAttrs } = this.$attrs;
3535
const collapsePanelClassName = {
36-
[className]: className,
36+
[className as string]: className,
3737
[`${prefixCls}-no-arrow`]: !showArrow,
3838
};
3939

components/drawer/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ const Drawer = defineComponent({
225225
const handler = getComponent(this, 'handle') || false;
226226
const getPrefixCls = this.configProvider.getPrefixCls;
227227
const prefixCls = getPrefixCls('drawer', customizePrefixCls);
228-
const { class: className } = this.$attrs as any;
228+
const { class: className } = this.$attrs;
229229
const vcDrawerProps: any = {
230230
...this.$attrs,
231231
...omit(rest, [
@@ -253,7 +253,7 @@ const Drawer = defineComponent({
253253
showMask: mask,
254254
placement,
255255
class: classnames({
256-
[className]: !!className,
256+
[className as string]: !!className,
257257
[wrapClassName]: !!wrapClassName,
258258
[haveMask]: !!haveMask,
259259
}),

components/form/Form.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const FormProps = {
5252
prefixCls: PropTypes.string,
5353
hideRequiredMark: PropTypes.looseBool,
5454
model: PropTypes.object,
55-
rules: { type: Object as PropType<{[k: string]: ValidationRule[] | ValidationRule}> },
55+
rules: { type: Object as PropType<{ [k: string]: ValidationRule[] | ValidationRule }> },
5656
validateMessages: PropTypes.object,
5757
validateOnRuleChange: PropTypes.looseBool,
5858
// 提交失败自动滚动到第一个错误字段
@@ -63,7 +63,7 @@ export const FormProps = {
6363
validateTrigger: { type: [String, Array] as PropType<string | string[]> },
6464
};
6565

66-
function isEqualName(name1: any, name2: any) {
66+
function isEqualName(name1: NamePath, name2: NamePath) {
6767
return isEqual(toArray(name1), toArray(name2));
6868
}
6969

components/input/ResizableTextArea.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const ResizableTextArea = defineComponent({
6464
saveTextArea(textArea: HTMLTextAreaElement) {
6565
this.textArea = textArea;
6666
},
67-
handleResize(size: any) {
67+
handleResize(size: { width: number; height: number }) {
6868
const { resizeStatus } = this.$data;
6969

7070
if (resizeStatus !== RESIZE_STATUS_NONE) {

components/input/calculateNodeHeight.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export default function calculateNodeHeight(
120120
let minHeight = Number.MIN_SAFE_INTEGER;
121121
let maxHeight = Number.MAX_SAFE_INTEGER;
122122
let height = hiddenTextarea.scrollHeight;
123-
let overflowY: any;
123+
let overflowY: string;
124124

125125
if (boxSizing === 'border-box') {
126126
// border-box: add border, since height = content + padding + border

0 commit comments

Comments
 (0)