You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, thank you for creating this cool library. It offers flexibility that other schema-based solutions don't, and I've been enjoying it so far.
My issue is that when I try to follow the skipWhen example in the doc, my editor (TypeScript, to be more precise) starts complaining.
My example suite:
exportconstcreateSuite=(field: string,context: any)=>create((form: Partial<RegisterForm>={},field: string)=>{only(field);// nametest('name','Username is required',()=>{enforce(form.name).isNotBlank();});test('name','Username must be at least 2 characters long',()=>{enforce(form.name).longerThan(1);});test('name','Name can have at most 18 characters',()=>{enforce(form.name).shorterThan(19);});skipWhen((res)=>res.hasErrors('name'),()=>{test('name',`Name ${form.name} already taken`,()=>{if(!context.userService)returnPromise.resolve(true);constservice=context.userServiceasUserService;returnservice.isUsernameUnique(form.name??'');});},);});
But TS is reporting errors on line "test('name', Name ${form.name} already taken, () => {":
Diagnostics:
1. No overload matches this call.
Overload 1 of 4, '(fieldName: "name", message: string, cb: TestFn): TIsolateTest<string, string>', gave the following error.
Argument of type '() => Promise<boolean>' is not assignable to parameter of type 'TestFn'.
Type 'Promise<boolean>' is not assignable to type 'TestResult'.
Type 'Promise<boolean>' is not assignable to type 'AsyncTest'.
Type 'boolean' is not assignable to type 'void'.
Overload 2 of 4, '(fieldName: "name", cb: TestFn, key: IsolateKey): TIsolateTest<string, string>', gave the following error.
Argument of type 'string' is not assignable to parameter of type 'TestFn'. [2769
It also happens with the minimal example in the doc:
exportdefaultcreate((data={})=>{test('username','Username is required',()=>{enforce(data.username).isNotBlank();});skipWhen((res)=>res.hasErrors('username'),()=>{test('username','Username already exists',async()=>{// this is an example for a server callreturntrue;});},);});
Any help is appreciated. Thanks.
Versions
vest: 5.4.5
typescript: 5.5.4
The text was updated successfully, but these errors were encountered:
First, thank you for creating this cool library. It offers flexibility that other schema-based solutions don't, and I've been enjoying it so far.
My issue is that when I try to follow the
skipWhen
example in the doc, my editor (TypeScript, to be more precise) starts complaining.My example suite:
But TS is reporting errors on line "test('name',
Name ${form.name} already taken
, () => {":It also happens with the minimal example in the doc:
Any help is appreciated. Thanks.
Versions
vest
: 5.4.5typescript
: 5.5.4The text was updated successfully, but these errors were encountered: