You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make the second argument be of the type string | number. If it's a number assume it's the id, and if it's a string assume it's the username. This might be the safest backward-compatible option.
Make the second argument an object of the type { username: string } | { userId: number } and send some of them conditionally when calling the API.
Make the user_id and username fields part of the options argument instead of being an argument on itself.
Checklist
I have checked that this is not a duplicate issue.
I have read the documentation.
The text was updated successfully, but these errors were encountered:
Description
The method
ProjectMembers#add
should be able to receive the username as an alternative to the user_id since the API allows it.Steps to reproduce
client.ProjectMembers.add('repo_id', 'username', AccessLevel.MAINTAINER)
Expected behaviour
It should not cause a type error and should call this API endpoint passing the username as the
username
field of the API endpoint payloadActual behaviour
It causes a type error saying 'username' can't be a string, since the method assumes the second parameter is the user_id (source: https://github.com/jdalrymple/gitbeaker/blob/main/packages/core/src/resources/ProjectMembers.ts#L21), which is a number. Even if the type was right, the implementation still passes this attribute as the
userId
of the API (source: https://github.com/jdalrymple/gitbeaker/blob/main/packages/core/src/templates/ResourceMembers.ts#L67).Possible fixes
I see three possibilities here:
string | number
. If it's a number assume it's the id, and if it's a string assume it's the username. This might be the safest backward-compatible option.{ username: string } | { userId: number }
and send some of them conditionally when calling the API.options
argument instead of being an argument on itself.Checklist
The text was updated successfully, but these errors were encountered: