fix: Fix error due to Typescript 3.5.1

encodeURIComponent() does not handle undefined.
To be precise, it actually does and returns undefined, but normally
that is an error, so the Typescript definition wants sensible input
values, i.e. string | number | boolean.
This commit is contained in:
Daniel Rose 2019-06-12 13:31:32 +02:00
parent 5474f0658f
commit bd4e14107e

View File

@ -87,11 +87,12 @@ class MergeRequests extends BaseService {
projectId: ProjectId,
{ mergerequestIId, ...options }: { mergerequestIId?: MergeRequestId } & BaseRequestOptions,
) {
const [pId, mIId] = [projectId, mergerequestIId].map(encodeURIComponent);
const pId = encodeURIComponent(projectId);
let url;
if (mergerequestIId) {
const mIId = encodeURIComponent(mergerequestIId);
url = `projects/${pId}/merge_requests/${mIId}/approvals`;
} else {
url = `projects/${pId}/approvals`;
@ -106,11 +107,12 @@ class MergeRequests extends BaseService {
approverGroupIds: GroupId[],
{ mergerequestIId, ...options }: { mergerequestIId?: MergeRequestId } & BaseRequestOptions,
) {
const [pId, mIId] = [projectId, mergerequestIId].map(encodeURIComponent);
const pId = encodeURIComponent(projectId);
let url;
if (mergerequestIId) {
const mIId = encodeURIComponent(mergerequestIId);
url = `projects/${pId}/merge_requests/${mIId}/approvers`;
} else {
url = `projects/${pId}/approvers`;
@ -179,11 +181,12 @@ class MergeRequests extends BaseService {
projectId: ProjectId,
{ mergerequestIId, ...options }: { mergerequestIId?: MergeRequestId } & BaseRequestOptions,
) {
const [pId, mIId] = [projectId, mergerequestIId].map(encodeURIComponent);
const pId = encodeURIComponent(projectId);
let url;
if (mergerequestIId) {
const mIId = encodeURIComponent(mergerequestIId);
url = `projects/${pId}/merge_requests/${mIId}/approvals`;
} else {
url = `projects/${pId}/approvals`;