豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit ba8f786

Browse files
committed
fix(ng-dev): assorted typing fixes that typescript wants (#774)
Types has begun to want more specific commits in some of our mapping functions related to Github API responses. PR Close #774
1 parent 8d1d6c5 commit ba8f786

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

ng-dev/caretaker/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ts_library(
1010
deps = [
1111
"//ng-dev/release/versioning",
1212
"//ng-dev/utils",
13+
"@npm//@octokit/plugin-rest-endpoint-methods",
1314
"@npm//@types/inquirer",
1415
"@npm//@types/node",
1516
"@npm//@types/yargs",

ng-dev/caretaker/handoff/update-github-team.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import {getConfig} from '../../utils/config.js';
1212
import {green, Log, yellow} from '../../utils/logging.js';
1313
import {AuthenticatedGitClient} from '../../utils/git/authenticated-git-client.js';
1414
import {assertValidCaretakerConfig} from '../config.js';
15+
import {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods';
16+
17+
type GithubOrgMember =
18+
RestEndpointMethodTypes['teams']['listMembersInOrg']['response']['data'][number];
1519

1620
/** Update the Github caretaker group, using a prompt to obtain the new caretaker group members. */
1721
export async function updateCaretakerTeamViaPrompt() {
@@ -86,8 +90,8 @@ async function getGroupMembers(group: string) {
8690
team_slug: group,
8791
})
8892
).data
89-
.filter((_) => !!_)
90-
.map((member) => member!.login);
93+
.filter((member: GithubOrgMember) => !!member)
94+
.map((member: GithubOrgMember) => member!.login);
9195
}
9296

9397
async function setCaretakerGroup(group: string, members: string[]) {
@@ -98,7 +102,7 @@ async function setCaretakerGroup(group: string, members: string[]) {
98102
/** The list of current members of the group. */
99103
const current = await getGroupMembers(group);
100104
/** The list of users to be removed from the group. */
101-
const removed = current.filter((login) => !members.includes(login));
105+
const removed = current.filter((login: string) => !members.includes(login));
102106
/** Add a user to the group. */
103107
const add = async (username: string) => {
104108
Log.debug(`Adding ${username} to ${fullSlug}.`);

ng-dev/pr/check-target-branches/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ts_library(
99
"//ng-dev/pr/config",
1010
"//ng-dev/release/versioning",
1111
"//ng-dev/utils",
12+
"@npm//@octokit/plugin-rest-endpoint-methods",
1213
"@npm//@types/yargs",
1314
],
1415
)

ng-dev/pr/check-target-branches/check-target-branches.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import {assertValidPullRequestConfig, PullRequestConfig} from '../config/index.j
1313
import {getTargetBranchesAndLabelForPullRequest} from '../common/targeting/target-label.js';
1414
import {ActiveReleaseTrains} from '../../release/versioning/active-release-trains.js';
1515
import {getNextBranchName} from '../../release/versioning/version-branches.js';
16+
import {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods';
17+
18+
type GithubLabel = RestEndpointMethodTypes['pulls']['get']['response']['data']['labels'][number];
1619

1720
async function getTargetBranchesForPr(
1821
prNumber: number,
@@ -30,7 +33,7 @@ async function getTargetBranchesForPr(
3033
// here.
3134
// TODO(devversion): Remove the non-null cast once
3235
// https://github.com/github/rest-api-description/issues/169 is fixed.
33-
const labels = prData.labels.map((l) => l.name!);
36+
const labels = prData.labels.map((l: GithubLabel) => l.name!);
3437
/** The branch targetted via the Github UI. */
3538
const githubTargetBranch = prData.base.ref;
3639

ng-dev/pr/merge/strategies/api-merge.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import {FatalMergeToolError, MergeConflictsFatalError} from '../failures.js';
2020

2121
/** Type describing the parameters for the Octokit `merge` API endpoint. */
2222
type OctokitMergeParams = RestEndpointMethodTypes['pulls']['merge']['parameters'];
23+
type OctokitListCommitsEntry =
24+
RestEndpointMethodTypes['pulls']['listCommits']['response']['data'][number];
2325

2426
/** Separator between commit message header and body. */
2527
const COMMIT_HEADER_SEPARATOR = '\n\n';
@@ -183,12 +185,12 @@ export class GithubApiMergeStrategy extends MergeStrategy {
183185
}
184186

185187
/** Gets all commit messages of commits in the pull request. */
186-
private async _getPullRequestCommitMessages({prNumber}: PullRequest) {
188+
private async _getPullRequestCommitMessages({prNumber}: PullRequest): Promise<string[]> {
187189
const allCommits = await this.git.github.paginate(this.git.github.pulls.listCommits, {
188190
...this.git.remoteParams,
189191
pull_number: prNumber,
190192
});
191-
return allCommits.map(({commit}) => commit.message);
193+
return allCommits.map(({commit}: OctokitListCommitsEntry) => commit.message);
192194
}
193195

194196
/** Determines the merge action from the given pull request. */

0 commit comments

Comments
 (0)