Skip to content

Commit 03b33c0

Browse files
committed
build: react-hook-form build failed
1 parent 560ef2c commit 03b33c0

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

web/src/types/schema.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { TFunction } from "i18next";
22
import { useCallback } from "react";
3-
import type { FieldErrors } from "react-hook-form";
3+
import type { FieldErrors, ResolverResult } from "react-hook-form";
44
import * as yup from "yup";
55
import { ShellToolType } from "./memshell";
66

@@ -29,10 +29,7 @@ export const memShellFormSchema = yup.object({
2929
encryptor: yup.string().optional(),
3030
});
3131

32-
interface ValidationResult {
33-
values: MemShellFormSchema;
34-
errors: FieldErrors<MemShellFormSchema>;
35-
}
32+
type ValidationResult = ResolverResult<MemShellFormSchema>;
3633

3734
const urlPatternIsNeeded = (shellType: string) => {
3835
if (shellType.startsWith("Agent")) {
@@ -58,7 +55,10 @@ export const useYupValidationResolver = (
5855
t: TFunction,
5956
) =>
6057
useCallback(
61-
async (data: MemShellFormSchema): Promise<ValidationResult> => {
58+
async (
59+
data: MemShellFormSchema,
60+
_context: any,
61+
): Promise<ValidationResult> => {
6262
try {
6363
const values = (await validationSchema.validate(data, {
6464
abortEarly: false,
@@ -105,7 +105,7 @@ export const useYupValidationResolver = (
105105
} catch (errors) {
106106
if (errors instanceof yup.ValidationError) {
107107
return {
108-
values: {} as MemShellFormSchema,
108+
values: {},
109109
errors: errors.inner.reduce(
110110
(allErrors, currentError) => {
111111
allErrors[currentError.path as keyof MemShellFormSchema] = {
@@ -120,7 +120,7 @@ export const useYupValidationResolver = (
120120
}
121121

122122
return {
123-
values: {} as MemShellFormSchema,
123+
values: {},
124124
errors: {
125125
server: {
126126
type: "unknown",
@@ -154,17 +154,17 @@ export const probeShellFormSchema = yup.object().shape({
154154
shrink: yup.boolean().optional(),
155155
});
156156

157-
interface ProbeValidationResult {
158-
values: ProbeShellFormSchema;
159-
errors: FieldErrors<ProbeShellFormSchema>;
160-
}
157+
type ProbeValidationResult = ResolverResult<ProbeShellFormSchema>;
161158

162159
export const useYupValidationProbeResolver = (
163160
validationSchema: yup.ObjectSchema<any>,
164161
t: TFunction,
165162
) =>
166163
useCallback(
167-
async (data: ProbeShellFormSchema): Promise<ProbeValidationResult> => {
164+
async (
165+
data: ProbeShellFormSchema,
166+
_context: any,
167+
): Promise<ProbeValidationResult> => {
168168
try {
169169
const values = (await validationSchema.validate(data, {
170170
abortEarly: false,
@@ -194,7 +194,7 @@ export const useYupValidationProbeResolver = (
194194
} catch (errors) {
195195
if (errors instanceof yup.ValidationError) {
196196
return {
197-
values: {} as ProbeShellFormSchema,
197+
values: {},
198198
errors: errors.inner.reduce(
199199
(allErrors, currentError) => {
200200
allErrors[currentError.path as keyof ProbeShellFormSchema] = {
@@ -210,7 +210,7 @@ export const useYupValidationProbeResolver = (
210210
}
211211

212212
return {
213-
values: {} as ProbeShellFormSchema,
213+
values: {},
214214
errors: {
215215
server: {
216216
type: "unknown",

0 commit comments

Comments
 (0)