File tree Expand file tree Collapse file tree 4 files changed +25
-11
lines changed Expand file tree Collapse file tree 4 files changed +25
-11
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @clerk/clerk-js " : patch
3+ " @clerk/types " : patch
4+ ---
5+
6+ Update the experimental ` Errors ` interface to allow null for raw and global error arrays
Original file line number Diff line number Diff line change @@ -52,30 +52,38 @@ function errorsToParsedErrors(error: unknown): Errors {
5252 captcha : null ,
5353 legalAccepted : null ,
5454 } ,
55- raw : [ ] ,
56- global : [ ] ,
55+ raw : null ,
56+ global : null ,
5757 } ;
5858
5959 if ( ! error ) {
6060 return parsedErrors ;
6161 }
6262
6363 if ( ! isClerkAPIResponseError ( error ) ) {
64- parsedErrors . raw . push ( error ) ;
65- parsedErrors . global . push ( error ) ;
64+ parsedErrors . raw = [ error ] ;
65+ parsedErrors . global = [ error ] ;
6666 return parsedErrors ;
6767 }
6868
69- parsedErrors . raw . push ( ...error . errors ) ;
70-
7169 error . errors . forEach ( error => {
70+ if ( parsedErrors . raw ) {
71+ parsedErrors . raw . push ( error ) ;
72+ } else {
73+ parsedErrors . raw = [ error ] ;
74+ }
75+
7276 if ( 'meta' in error && error . meta && 'paramName' in error . meta ) {
7377 const name = snakeToCamel ( error . meta . paramName ) ;
7478 parsedErrors . fields [ name as keyof typeof parsedErrors . fields ] = error ;
7579 return ;
7680 }
7781
78- parsedErrors . global . push ( error ) ;
82+ if ( parsedErrors . global ) {
83+ parsedErrors . global . push ( error ) ;
84+ } else {
85+ parsedErrors . global = [ error ] ;
86+ }
7987 } ) ;
8088
8189 return parsedErrors ;
Original file line number Diff line number Diff line change @@ -17,8 +17,8 @@ const defaultErrors = (): Errors => ({
1717 captcha : null ,
1818 legalAccepted : null ,
1919 } ,
20- raw : [ ] ,
21- global : [ ] ,
20+ raw : null ,
21+ global : null ,
2222} ) ;
2323
2424export class StateProxy implements State {
Original file line number Diff line number Diff line change @@ -76,11 +76,11 @@ export interface Errors {
7676 /**
7777 * The raw, unparsed errors from the Clerk API.
7878 */
79- raw : unknown [ ] ;
79+ raw : unknown [ ] | null ;
8080 /**
8181 * Parsed errors that are not related to any specific field.
8282 */
83- global : unknown [ ] ; // does not include any errors that could be parsed as a field error
83+ global : unknown [ ] | null ; // does not include any errors that could be parsed as a field error
8484}
8585
8686/**
You can’t perform that action at this time.
0 commit comments