From 9bb3dd7ef183b3e17343d7467125cd8fe1430f11 Mon Sep 17 00:00:00 2001 From: Sam Chung Date: Thu, 20 Jun 2024 11:34:29 +1000 Subject: [PATCH] Explicitly declare return types (#1589) Co-authored-by: Ryan Ling --- .changeset/friendly-houses-promise.md | 5 +++++ src/api/git/pull.ts | 2 +- src/api/git/push.ts | 15 ++++++++++++++- src/api/github/push.ts | 15 ++++++++++----- 4 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 .changeset/friendly-houses-promise.md diff --git a/.changeset/friendly-houses-promise.md b/.changeset/friendly-houses-promise.md new file mode 100644 index 000000000..b342c4f74 --- /dev/null +++ b/.changeset/friendly-houses-promise.md @@ -0,0 +1,5 @@ +--- +'skuba': patch +--- + +Git: Explicitly declare return types to enable compatibility with the `Node16` module diff --git a/src/api/git/pull.ts b/src/api/git/pull.ts index 6c146b63c..7a8c2ba20 100644 --- a/src/api/git/pull.ts +++ b/src/api/git/pull.ts @@ -51,7 +51,7 @@ export const fastForwardBranch = async ({ ref, remote, remoteRef, -}: PullParameters) => { +}: PullParameters): Promise => { const { owner, repo } = await getOwnerAndRepo({ dir }); const url = `https://github.com/${encodeURIComponent( diff --git a/src/api/git/push.ts b/src/api/git/push.ts index f7a30f85b..7054bb208 100644 --- a/src/api/git/push.ts +++ b/src/api/git/push.ts @@ -51,6 +51,19 @@ interface PushParameters { force?: boolean; } +interface PushResult { + ok: boolean; + error: string | null; + refs: Record< + string, + { + ok: boolean; + error: string; + } + >; + headers?: Record | undefined; +} + /** * Pushes the specified `ref` from the local Git repository to a remote. */ @@ -61,7 +74,7 @@ export const push = async ({ remote, remoteRef, force, -}: PushParameters) => { +}: PushParameters): Promise => { const { owner, repo } = await getOwnerAndRepo({ dir }); const url = `https://github.com/${encodeURIComponent( diff --git a/src/api/github/push.ts b/src/api/github/push.ts index 6f26dd6a5..480944f53 100644 --- a/src/api/github/push.ts +++ b/src/api/github/push.ts @@ -1,10 +1,6 @@ import path from 'path'; -import type { - CreateCommitOnBranchInput, - FileAddition, - FileDeletion, -} from '@octokit/graphql-schema'; +import type { CreateCommitOnBranchInput } from '@octokit/graphql-schema'; import fs from 'fs-extra'; import * as Git from '../git'; @@ -101,6 +97,15 @@ export const uploadAllFileChanges = async ({ return commitId; }; +interface FileAddition { + contents: unknown; + path: string; +} + +interface FileDeletion { + path: string; +} + export interface FileChanges { additions: FileAddition[]; deletions: FileDeletion[];