1
1
import type {
2
+ Autocomplete ,
2
3
ClerkPaginatedResponse ,
3
4
ClerkResourceReloadParams ,
4
5
GetUserOrganizationMembershipParams ,
@@ -20,9 +21,7 @@ export class OrganizationMembership extends BaseResource implements Organization
20
21
/**
21
22
* @experimental The property is experimental and subject to change in future releases.
22
23
*/
23
- // Adding (string & {}) allows for getting eslint autocomplete but also accepts any string
24
- // eslint-disable-next-line
25
- permissions : ( OrganizationPermission | ( string & { } ) ) [ ] = [ ] ;
24
+ permissions : Autocomplete < OrganizationPermission > [ ] = [ ] ;
26
25
role ! : MembershipRole ;
27
26
createdAt ! : Date ;
28
27
updatedAt ! : Date ;
@@ -41,8 +40,16 @@ export class OrganizationMembership extends BaseResource implements Organization
41
40
search : convertPageToOffset ( { ...retrieveMembershipsParams , paginated : true } ) as any ,
42
41
} )
43
42
. then ( res => {
43
+ if ( ! res ?. response ) {
44
+ return {
45
+ total_count : 0 ,
46
+ data : [ ] ,
47
+ } ;
48
+ }
49
+
50
+ // TODO: Fix typing
44
51
const { data : suggestions , total_count } =
45
- res ? .response as unknown as ClerkPaginatedResponse < OrganizationMembershipJSON > ;
52
+ res . response as unknown as ClerkPaginatedResponse < OrganizationMembershipJSON > ;
46
53
47
54
return {
48
55
total_count,
@@ -99,9 +106,16 @@ export class OrganizationMembership extends BaseResource implements Organization
99
106
} ,
100
107
{ forceUpdateClient : true } ,
101
108
) ;
102
- const currentMembership = ( json ?. response as unknown as OrganizationMembershipJSON [ ] ) . find (
109
+
110
+ if ( ! json ?. response ) {
111
+ return this . fromJSON ( null ) ;
112
+ }
113
+
114
+ // TODO: Fix typing
115
+ const currentMembership = ( json . response as unknown as OrganizationMembershipJSON [ ] ) . find (
103
116
orgMem => orgMem . id === this . id ,
104
117
) ;
118
+
105
119
return this . fromJSON ( currentMembership as OrganizationMembershipJSON ) ;
106
120
}
107
121
}
0 commit comments