Skip to content
This repository was archived by the owner on Aug 18, 2021. It is now read-only.

Commit c5bcb5a

Browse files
committed
fix: useForm type error in TSX
1 parent 95ff7b8 commit c5bcb5a

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"prepublishOnly": "npm run lint && npm run compile && npm run test"
2424
},
2525
"dependencies": {
26-
"@vue/runtime-dom": "^3.0.0-rc.1",
26+
"@vue/runtime-dom": "^3.0.0",
2727
"async-validator": "^3.4.0",
2828
"lodash-es": "^4.17.15",
2929
"resize-observer-polyfill": "^1.5.1"
@@ -45,7 +45,7 @@
4545
"@vue/eslint-config-prettier": "^6.0.0",
4646
"@vue/eslint-config-typescript": "^5.1.0",
4747
"@vue/test-utils": "^2.0.0-beta.3",
48-
"ant-design-vue": "^2.0.0-beta.9",
48+
"ant-design-vue": "^2.0.0-0",
4949
"babel-jest": "^26.1.0",
5050
"babel-loader": "^8.1.0",
5151
"css-loader": "^3.4.2",

src/useForm/index.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { reactive, watch, nextTick } from '@vue/runtime-dom';
1+
import { reactive, watch, nextTick, ExtractPropTypes } from '@vue/runtime-dom';
22
import cloneDeep from 'lodash-es/cloneDeep';
33
import intersection from 'lodash-es/intersection';
44
import isEqual from 'lodash-es/isEqual';
55
import debounce from 'lodash-es/debounce';
66
import omit from 'lodash-es/omit';
7+
import { FormItemProps as formItemProps } from 'ant-design-vue/es/form/FormItem';
78
import { validateRules } from 'ant-design-vue/es/form/utils/validateUtil';
89
import { defaultValidateMessages } from 'ant-design-vue/es/form/utils/messages';
910
import { allPromiseFinish } from 'ant-design-vue/es/form/utils/asyncUtil';
@@ -16,6 +17,8 @@ interface DebounceSettings {
1617
trailing?: boolean;
1718
}
1819

20+
type FormItemProps = Partial<ExtractPropTypes<typeof formItemProps>>;
21+
1922
function isRequired(rules: any[]) {
2023
let isRequired = false;
2124
if (rules && rules.length) {
@@ -101,7 +104,7 @@ type namesType = string | string[];
101104
export interface validateInfo {
102105
autoLink?: boolean;
103106
required?: boolean;
104-
validateStatus?: 'validating' | 'error' | 'success' | null;
107+
validateStatus?: FormItemProps['validateStatus'];
105108
help?: string;
106109
}
107110

@@ -278,7 +281,12 @@ function useForm(
278281

279282
return returnPromise;
280283
};
281-
const validateField = <T extends unknown = any>(name: string, value: any, rules: any, option: validateOptions): Promise<T> => {
284+
const validateField = <T extends unknown = any>(
285+
name: string,
286+
value: any,
287+
rules: any,
288+
option: validateOptions,
289+
): Promise<T> => {
282290
const promise = validateRules(
283291
[name],
284292
value,
@@ -301,7 +309,10 @@ function useForm(
301309
return promise;
302310
};
303311

304-
const validate = <T extends unknown = any>(names?: namesType, option?: validateOptions): Promise<T> => {
312+
const validate = <T extends unknown = any>(
313+
names?: namesType,
314+
option?: validateOptions,
315+
): Promise<T> => {
305316
let keys = [];
306317
let strict = true;
307318
if (!names) {

0 commit comments

Comments
 (0)