Skip to content

Commit a91a4a3

Browse files
committed
Cleanup: use more specific types
1 parent 2fd1503 commit a91a4a3

2 files changed

Lines changed: 10 additions & 15 deletions

File tree

src/githubHelper.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,12 @@ export class GithubHelper {
313313
* Replaces newlines and tabs with spaces. No attempt is made to remove e.g. Markdown
314314
* links or other special formatting.
315315
*/
316-
async updateRepositoryDescription(description) {
317-
let props : RestEndpointMethodTypes["repos"]["update"]["parameters"] = {
316+
async updateRepositoryDescription(description: string) {
317+
let props: RestEndpointMethodTypes['repos']['update']['parameters'] = {
318318
owner: this.githubOwner,
319319
repo: this.githubRepo,
320-
description: description.replace(/\s+/g, " ")
321-
}
320+
description: description.replace(/\s+/g, ' '),
321+
};
322322
return this.githubApi.repos.update(props);
323323
}
324324

@@ -355,7 +355,7 @@ export class GithubHelper {
355355
/**
356356
* Converts GitLab assignees to GitHub usernames, using settings.usermap
357357
*/
358-
convertAssignees(item: Partial<GitLabIssue | GitLabMergeRequest>): string[] {
358+
convertAssignees(item: GitLabIssue | GitLabMergeRequest): string[] {
359359
if (!item.assignees) return [];
360360
let assignees: string[] = [];
361361
for (let assignee of item.assignees) {
@@ -375,9 +375,7 @@ export class GithubHelper {
375375
* Note that this requires milestoneMap to be built, either during migration
376376
* or read from GitHub using registerMilestoneMap()
377377
*/
378-
convertMilestone(
379-
item: Partial<GitLabIssue | GitLabMergeRequest>
380-
): number | undefined {
378+
convertMilestone(item: GitLabIssue | GitLabMergeRequest): number | undefined {
381379
if (!this.milestoneMap) throw Error('this.milestoneMap not initialised');
382380
if (!item.milestone) return undefined;
383381

@@ -392,7 +390,7 @@ export class GithubHelper {
392390
*
393391
* This also adds "has attachment" if the issue links to data.
394392
*/
395-
convertLabels(item: Partial<GitLabIssue | GitLabMergeRequest>): string[] {
393+
convertLabels(item: GitLabIssue | GitLabMergeRequest): string[] {
396394
let labels: string[] = [];
397395
if (item.labels) {
398396
labels = item.labels.filter(l => {
@@ -1191,7 +1189,7 @@ export class GithubHelper {
11911189
title: string = '',
11921190
repo: string = ''
11931191
) => {
1194-
let milestone: Partial<SimpleMilestone> = {};
1192+
let milestone: SimpleMilestone;
11951193
if (this.milestoneMap) {
11961194
if (number) {
11971195
milestone = this.milestoneMap.get(parseInt(number)) ?? {

src/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function createPlaceholderIssue(expectedIdx: number): Partial<GitLabIssue> {
141141
* This is used for issues where the migration fails. The replacement issue will
142142
* have the same number and title, but the original description will be lost.
143143
*/
144-
function createReplacementIssue(issue: Partial<GitLabIssue>) {
144+
function createReplacementIssue(issue: GitLabIssue) {
145145
let description = `The original issue\n\n\tId: ${issue.iid}\n\tTitle: ${issue.title}\n\ncould not be created.\nThis is a dummy issue, replacing the original one.`;
146146

147147
if (issue.web_url) {
@@ -217,10 +217,7 @@ async function migrate() {
217217
async function transferDescription() {
218218
inform('Transferring Description');
219219

220-
// Get the description of this project
221-
let project = await gitlabApi.Projects.show(
222-
settings.gitlab.projectId
223-
) as any;
220+
let project = await gitlabApi.Projects.show(settings.gitlab.projectId);
224221

225222
await githubHelper.updateRepositoryDescription(project.description);
226223
}

0 commit comments

Comments
 (0)