@@ -240,6 +240,7 @@ function _stringProxy<
240240 } ;
241241}
242242
243+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
243244type ArrayFieldErrors = any [ ] ;
244245
245246export function arrayProxy <
@@ -256,37 +257,34 @@ export function arrayProxy<
256257 errors : Writable < string [ ] | undefined > ;
257258 fieldErrors : Writable < ArrayFieldErrors > ;
258259} {
259- const allErrors = fieldProxy (
260+ const formErrors = fieldProxy (
260261 superForm . errors ,
261262 // eslint-disable-next-line @typescript-eslint/no-explicit-any
262263 `${ path } ` as any
263264 ) ;
264265
265- const onlyFieldErrors = derived < typeof allErrors , ArrayFieldErrors > (
266- allErrors ,
266+ const onlyFieldErrors = derived < typeof formErrors , ArrayFieldErrors > (
267+ formErrors ,
267268 ( $errors ) => {
268269 const output : ArrayFieldErrors = [ ] ;
269270 for ( const key in $errors ) {
270271 if ( key == '_errors' ) continue ;
271- output [ key ] = $errors [ key ] ;
272+ output [ key as unknown as number ] = $errors [ key ] ;
272273 }
273274 return output as ArrayFieldErrors ;
274275 }
275276 ) ;
276277
277278 function updateArrayErrors (
278- errors : Record < number , any > | undefined ,
279+ errors : Record < number , unknown > ,
279280 value : ArrayFieldErrors
280281 ) {
281- if ( errors !== undefined ) {
282- for ( const key in errors ) {
283- if ( key == '_errors' ) continue ;
284- errors [ key ] = undefined ;
285- }
282+ for ( const key in errors ) {
283+ if ( key == '_errors' ) continue ;
284+ errors [ key ] = undefined ;
286285 }
287286 if ( value !== undefined ) {
288287 for ( const key in value ) {
289- if ( errors === undefined ) errors = { } ;
290288 errors [ key ] = value [ key ] ;
291289 }
292290 }
@@ -296,12 +294,14 @@ export function arrayProxy<
296294 const fieldErrors : Writable < ArrayFieldErrors > = {
297295 subscribe : onlyFieldErrors . subscribe ,
298296 update ( upd : Updater < ArrayFieldErrors > ) {
299- allErrors . update ( ( $errors ) =>
297+ formErrors . update ( ( $errors ) =>
298+ // @ts -expect-error Type is correct
300299 updateArrayErrors ( $errors , upd ( $errors ) )
301300 ) ;
302301 } ,
303302 set ( value : ArrayFieldErrors ) {
304- allErrors . update ( ( $errors ) => updateArrayErrors ( $errors , value ) ) ;
303+ // @ts -expect-error Type is correct
304+ formErrors . update ( ( $errors ) => updateArrayErrors ( $errors , value ) ) ;
305305 }
306306 } ;
307307
@@ -461,7 +461,7 @@ export function fieldProxy<T extends object, Path extends FormPath<T>>(
461461 update ( upd : Updater < FormPathType < T , Path > > ) {
462462 form . update ( ( f ) => {
463463 const output = traversePath ( f , path2 , ( { parent, key, value } ) => {
464- if ( value === undefined ) parent [ key ] = { } ;
464+ if ( value === undefined ) parent [ key ] = / \D / . test ( key ) ? { } : [ ] ;
465465 return parent [ key ] ;
466466 } ) ;
467467 if ( output ) output . parent [ output . key ] = upd ( output . value ) ;
@@ -471,7 +471,7 @@ export function fieldProxy<T extends object, Path extends FormPath<T>>(
471471 set ( value : FormPathType < T , Path > ) {
472472 form . update ( ( f ) => {
473473 const output = traversePath ( f , path2 , ( { parent, key, value } ) => {
474- if ( value === undefined ) parent [ key ] = { } ;
474+ if ( value === undefined ) parent [ key ] = / \D / . test ( key ) ? { } : [ ] ;
475475 return parent [ key ] ;
476476 } ) ;
477477 if ( output ) output . parent [ output . key ] = value ;
0 commit comments