Skip to content

Commit bd4e141

Browse files
committed
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.
1 parent 5474f06 commit bd4e141

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/services/MergeRequests.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ class MergeRequests extends BaseService {
8787
projectId: ProjectId,
8888
{ mergerequestIId, ...options }: { mergerequestIId?: MergeRequestId } & BaseRequestOptions,
8989
) {
90-
const [pId, mIId] = [projectId, mergerequestIId].map(encodeURIComponent);
90+
const pId = encodeURIComponent(projectId);
9191

9292
let url;
9393

9494
if (mergerequestIId) {
95+
const mIId = encodeURIComponent(mergerequestIId);
9596
url = `projects/${pId}/merge_requests/${mIId}/approvals`;
9697
} else {
9798
url = `projects/${pId}/approvals`;
@@ -106,11 +107,12 @@ class MergeRequests extends BaseService {
106107
approverGroupIds: GroupId[],
107108
{ mergerequestIId, ...options }: { mergerequestIId?: MergeRequestId } & BaseRequestOptions,
108109
) {
109-
const [pId, mIId] = [projectId, mergerequestIId].map(encodeURIComponent);
110+
const pId = encodeURIComponent(projectId);
110111

111112
let url;
112113

113114
if (mergerequestIId) {
115+
const mIId = encodeURIComponent(mergerequestIId);
114116
url = `projects/${pId}/merge_requests/${mIId}/approvers`;
115117
} else {
116118
url = `projects/${pId}/approvers`;
@@ -179,11 +181,12 @@ class MergeRequests extends BaseService {
179181
projectId: ProjectId,
180182
{ mergerequestIId, ...options }: { mergerequestIId?: MergeRequestId } & BaseRequestOptions,
181183
) {
182-
const [pId, mIId] = [projectId, mergerequestIId].map(encodeURIComponent);
184+
const pId = encodeURIComponent(projectId);
183185

184186
let url;
185187

186188
if (mergerequestIId) {
189+
const mIId = encodeURIComponent(mergerequestIId);
187190
url = `projects/${pId}/merge_requests/${mIId}/approvals`;
188191
} else {
189192
url = `projects/${pId}/approvals`;

0 commit comments

Comments
 (0)