From ef5f493ce489775fcfa7f8a862759fb0d6aa847c Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Wed, 3 Apr 2024 13:15:17 +0200 Subject: [PATCH] fix: typecheck --- .../awaitStagingDeploys/awaitStagingDeploys.ts | 6 +++--- .../getDeployPullRequestList.ts | 4 ++-- .github/libs/promiseWhile.ts | 12 +++++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys.ts b/.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys.ts index 958a643d4287..1cf58dc03f8f 100644 --- a/.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys.ts +++ b/.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ import lodashThrottle from 'lodash/throttle'; -import ActionUtils from '@github/libs/ActionUtils'; +import {getStringInput} from '@github/libs/ActionUtils'; import CONST from '@github/libs/CONST'; import GitHubUtils, {POLL_RATE} from '@github/libs/GithubUtils'; import {promiseDoWhile} from '@github/libs/promiseWhile'; @@ -9,11 +9,11 @@ type CurrentStagingDeploys = Awaited boolean, action: () => Promise): Promise { +function promiseWhile(condition: () => boolean, action: (() => Promise) | DebouncedFunc<() => Promise> | undefined): Promise { console.info('[promiseWhile] promiseWhile()'); return new Promise((resolve, reject) => { @@ -9,7 +11,7 @@ function promiseWhile(condition: () => boolean, action: () => Promise): Pr if (!condition()) { resolve(); } else { - const actionResult = action(); + const actionResult = action?.(); console.info('[promiseWhile] promiseWhile() actionResult', actionResult); Promise.resolve(actionResult).then(loop).catch(reject); } @@ -21,15 +23,15 @@ function promiseWhile(condition: () => boolean, action: () => Promise): Pr /** * Simulates a do-while loop where the condition is determined by the result of a Promise. */ -function promiseDoWhile(condition: () => boolean, action: () => Promise): Promise { +function promiseDoWhile(condition: () => boolean, action: (() => Promise) | DebouncedFunc<() => Promise> | undefined): Promise { console.info('[promiseWhile] promiseDoWhile()'); return new Promise((resolve, reject) => { console.info('[promiseWhile] promiseDoWhile() condition', condition); - const actionResult = action(); + const actionResult = action?.(); console.info('[promiseWhile] promiseDoWhile() actionResult', actionResult); actionResult - .then(() => promiseWhile(condition, action)) + ?.then(() => promiseWhile(condition, action)) .then(() => resolve()) .catch(reject); });