keycloak/keycloak-nodejs-admin-client

Users.find causes TS errors when passing possibly undefined filter params

backbone87 opened this issue · 0 comments

Describe the bug
Users.find causes TS errors when passing possibly undefined filter params

To Reproduce

  private getUsers(search?: string): Promise<UserRepresentation[]> {
    return this.keycloakAdminClient.users.find({ search });
  }
Argument of type '{ search: string | undefined; }' is not assignable to parameter of type 'UserQuery & { [key: string]: string | number; } & { realm?: string | undefined; }'.
  Type '{ search: string | undefined; }' is not assignable to type '{ [key: string]: string | number; }'.
    Property 'search' is incompatible with index signature.
      Type 'string | undefined' is not assignable to type 'string | number'.
        Type 'undefined' is not assignable to type 'string | number'.ts(2345)

Expected behavior
No type errors

Enviroment (please complete the following information):

  • Library Version: 1.14.21

Additional context
introduces in #195
typing should be changed to:

  public find = this.makeRequest<UserQuery & {[key: string]?: string | number}, UserRepresentation[]>({
    method: 'GET',
  });