Skip to content

Commit bc27729

Browse files
authored
Updates TypeScript (released 4.2) and Octokit (to get fixed types), and a couple minor others (#2525)
1 parent a3f8d1c commit bc27729

File tree

8 files changed

+43
-33
lines changed

8 files changed

+43
-33
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,8 +2043,8 @@
20432043
"webpack-cli": "4.2.0"
20442044
},
20452045
"dependencies": {
2046-
"@octokit/rest": "18.2.0",
2047-
"@octokit/types": "6.10.0",
2046+
"@octokit/rest": "18.2.1",
2047+
"@octokit/types": "6.10.1",
20482048
"@vscode/extension-telemetry": "0.6.2",
20492049
"apollo-boost": "^0.4.9",
20502050
"apollo-link-context": "1.0.20",

src/github/common.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@ import { Endpoints } from '@octokit/types';
44
export namespace OctokitCommon {
55
export type IssuesAssignParams = OctokitRest.RestEndpointMethodTypes['issues']['addAssignees']['parameters'];
66
export type IssuesCreateParams = OctokitRest.RestEndpointMethodTypes['issues']['create']['parameters'];
7-
export type IssuesCreateResponseData = Endpoints['POST /repos/{owner}/{repo}/issues']['response']['data'];
8-
export type IssuesListCommentsResponseData = Endpoints['GET /repos/{owner}/{repo}/issues/{issue_number}/comments']['response']['data'];
7+
export type IssuesCreateResponseData = OctokitRest.RestEndpointMethodTypes['issues']['create']['response']['data'];
8+
export type IssuesListCommentsResponseData = OctokitRest.RestEndpointMethodTypes['issues']['listComments']['response']['data'];
99
export type IssuesListEventsForTimelineResponseData = Endpoints['GET /repos/{owner}/{repo}/issues/{issue_number}/timeline']['response']['data'];
1010
export type IssuesListEventsForTimelineResponseItemActor = IssuesListEventsForTimelineResponseData[0]['actor'];
1111
export type PullsCreateParams = OctokitRest.RestEndpointMethodTypes['pulls']['create']['parameters'];
12-
export type PullsCreateResponseData = Endpoints['POST /repos/{owner}/{repo}/pulls']['response']['data'];
1312
export type PullsCreateReviewResponseData = Endpoints['POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews']['response']['data'];
1413
export type PullsCreateReviewCommentResponseData = Endpoints['POST /repos/{owner}/{repo}/pulls/{pull_number}/comments']['response']['data'];
15-
export type PullsGetResponseData = Endpoints['GET /repos/{owner}/{repo}/pulls/{pull_number}']['response']['data'];
14+
export type PullsGetResponseData = OctokitRest.RestEndpointMethodTypes['pulls']['get']['response']['data'];
1615
export type PullsGetResponseUser = Exclude<PullsGetResponseData['user'], null>;
1716
export type PullsListCommitsResponseData = Endpoints['GET /repos/{owner}/{repo}/pulls/{pull_number}/commits']['response']['data'];
1817
export type PullsListRequestedReviewersResponseData = Endpoints['GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers']['response']['data'];
19-
export type PullsListResponseItem = Endpoints['GET /repos/{owner}/{repo}/pulls']['response']['data'][0];
18+
export type PullsListResponseItem = OctokitRest.RestEndpointMethodTypes['pulls']['list']['response']['data'][0];
2019
export type PullsListResponseItemHead = PullsListResponseItem['head'];
2120
export type PullsListResponseItemBase = PullsListResponseItem['base'];
2221
export type PullsListResponseItemHeadRepo = PullsListResponseItemHead['repo'];
@@ -32,7 +31,7 @@ export namespace OctokitCommon {
3231
export type PullsListReviewRequestsResponseTeamsItem = Endpoints['GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers']['response']['data']['teams'][0];
3332
export type PullsListResponseItemHeadRepoTemplateRepository = PullsListResponseItem['head']['repo']['template_repository'];
3433
export type PullsListCommitsResponseItem = Endpoints['GET /repos/{owner}/{repo}/pulls/{pull_number}/commits']['response']['data'][0];
35-
export type ReposCompareCommitsResponseData = Endpoints['GET /repos/{owner}/{repo}/compare/{base}...{head}']['response']['data'];
34+
export type ReposCompareCommitsResponseData = OctokitRest.RestEndpointMethodTypes['repos']['compareCommits']['response']['data'];
3635
export type ReposGetCombinedStatusForRefResponseStatusesItem = Endpoints['GET /repos/{owner}/{repo}/commits/{ref}/status']['response']['data']['statuses'][0];
3736
export type ReposGetCommitResponseData = Endpoints['GET /repos/{owner}/{repo}/commits/{ref}']['response']['data'];
3837
export type ReposGetCommitResponseFiles = Endpoints['GET /repos/{owner}/{repo}/commits/{ref}']['response']['data']['files'];

src/github/githubRepository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,10 @@ export class GitHubRepository implements vscode.Disposable {
623623
try {
624624
Logger.debug(`Fork repository`, GitHubRepository.ID);
625625
const { octokit, remote } = await this.ensure();
626-
const result = (await octokit.call(octokit.api.repos.createFork, {
626+
const result = await octokit.call(octokit.api.repos.createFork, {
627627
owner: remote.owner,
628628
repo: remote.repositoryName,
629-
})) as any;
629+
});
630630
return result.data.clone_url;
631631
} catch (e) {
632632
Logger.appendLine(`GitHubRepository> Forking repository failed: ${e}`);

src/github/notifications.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ export class NotificationProvider implements vscode.Disposable {
300300
if (this._lastModified === headers['last-modified']) {
301301
return;
302302
}
303-
this._lastModified = headers['last-modified'];
303+
this._lastModified = headers['last-modified'] ?? '';
304304

305305
const prNodesToUpdate = this.uriFromNotifications();
306306
this._notifications.clear();

src/github/pullRequestModel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
10591059
}
10601060
})
10611061
]);
1062-
if (branch.data.protected && branch.data.protection.required_status_checks.enforcement_level !== 'off') {
1062+
if (branch.data.protected && branch.data.protection.required_status_checks && branch.data.protection.required_status_checks.enforcement_level !== 'off') {
10631063
// We need to add the "review required" check manually.
10641064
return {
10651065
id: REVIEW_REQUIRED_CHECK_ID,
@@ -1266,7 +1266,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
12661266
const MAX_FILE_CHANGES_IN_COMPARE_COMMITS = 100;
12671267
let files: IRawFileChange[] = [];
12681268

1269-
if (data.files.length >= MAX_FILE_CHANGES_IN_COMPARE_COMMITS) {
1269+
if (data.files && data.files.length >= MAX_FILE_CHANGES_IN_COMPARE_COMMITS) {
12701270
// compareCommits will return a maximum of 100 changed files
12711271
// If we have (maybe) more than that, we'll need to fetch them with listFiles API call
12721272
Logger.debug(
@@ -1280,7 +1280,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
12801280
});
12811281
} else {
12821282
// if we're under the limit, just use the result from compareCommits, don't make additional API calls.
1283-
files = data.files as IRawFileChange[];
1283+
files = data.files ? data.files as IRawFileChange[] : [];
12841284
}
12851285

12861286
if (oldHasChangesSinceReview !== undefined && oldHasChangesSinceReview !== this.hasChangesSinceLastReview && this.hasChangesSinceLastReview && this._showChangesSinceReview) {

src/github/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ export function convertRESTHeadToIGitHubRef(head: OctokitCommon.PullsListRespons
244244

245245
export function convertRESTPullRequestToRawPullRequest(
246246
pullRequest:
247-
| OctokitCommon.PullsCreateResponseData
248247
| OctokitCommon.PullsGetResponseData
249248
| OctokitCommon.PullsListResponseItem,
250249
githubRepository: GitHubRepository,
@@ -283,7 +282,7 @@ export function convertRESTPullRequestToRawPullRequest(
283282
: undefined,
284283
createdAt: created_at,
285284
updatedAt: updated_at,
286-
head: convertRESTHeadToIGitHubRef(head),
285+
head: head.repo ? convertRESTHeadToIGitHubRef(head as OctokitCommon.PullsListResponseItemHead) : undefined,
287286
base: convertRESTHeadToIGitHubRef(base),
288287
mergeable: (pullRequest as OctokitCommon.PullsGetResponseData).mergeable
289288
? PullRequestMergeability.Mergeable

src/view/compareChangesTreeDataProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ export class CompareChangesTreeProvider implements vscode.TreeDataProvider<TreeN
145145
head: `${this.compareOwner}:${this.compareBranchName}`,
146146
});
147147

148-
if (!data.files.length) {
148+
if (!data.files?.length) {
149149
this._view.message = `There are no commits between the base '${this.baseBranchName}' branch and the comparing '${this.compareBranchName}' branch`;
150150
} else if (this._isDisposed) {
151151
return [];
152152
} else {
153153
this._view.message = undefined;
154154
}
155155

156-
return data.files.map(file => {
156+
return data.files?.map(file => {
157157
return new GitHubFileChangeNode(
158158
this,
159159
file.filename,

yarn.lock

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@
214214
"@octokit/types" "^6.0.3"
215215
universal-user-agent "^6.0.0"
216216

217+
"@octokit/openapi-types@^12.11.0":
218+
version "12.11.0"
219+
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-12.11.0.tgz#da5638d64f2b919bca89ce6602d059f1b52d3ef0"
220+
integrity sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ==
221+
217222
"@octokit/openapi-types@^5.1.0", "@octokit/openapi-types@^5.3.2":
218223
version "5.3.2"
219224
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-5.3.2.tgz#b8ac43c5c3d00aef61a34cf744e315110c78deb4"
@@ -231,12 +236,12 @@
231236
resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.3.tgz#70a62be213e1edc04bb8897ee48c311482f9700d"
232237
integrity sha512-4RFU4li238jMJAzLgAwkBAw+4Loile5haQMQr+uhFq27BmyJXcXSKvoQKqh0agsZEiUlW6iSv3FAgvmGkur7OQ==
233238

234-
"@octokit/plugin-rest-endpoint-methods@4.12.0":
235-
version "4.12.0"
236-
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.12.0.tgz#1cec405cd4eaf0bdb58cb7d2a9b3d8473b3a70e8"
237-
integrity sha512-RgnQ1aoetdOJjZYC37LV5FNlL7GY/v1CdC5dur1Zp/UiADJlbRFbAz/xLx26ovXw67dK7EUtwCghS+6QyiI9RA==
239+
"@octokit/plugin-rest-endpoint-methods@4.12.2":
240+
version "4.12.2"
241+
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.12.2.tgz#d2bd0b794d6c11a13113db6199baf44a39b06f50"
242+
integrity sha512-5+MmGusB7wPw7OholtcGaMyjfrsFSpFqtJW8VsrbfU/TuaiQepY4wgVkS7P3TAObX257jrTbbGo/sJLcoGf16g==
238243
dependencies:
239-
"@octokit/types" "^6.10.0"
244+
"@octokit/types" "^6.10.1"
240245
deprecation "^2.3.1"
241246

242247
"@octokit/request-error@^2.0.0", "@octokit/request-error@^2.0.5":
@@ -262,30 +267,37 @@
262267
once "^1.4.0"
263268
universal-user-agent "^6.0.0"
264269

265-
"@octokit/rest@18.2.0":
266-
version "18.2.0"
267-
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.2.0.tgz#b75c87870bb1f7bc9f37ae0e9acb3a411a34a25f"
268-
integrity sha512-xsp6bIqL2sb/NmgLXTxw96caegobRw+YHnzdIi70ruquHtPPDW2cBAONhDYMUuAOeXx0JH2auOeplpk4SQJy1w==
270+
"@octokit/rest@18.2.1":
271+
version "18.2.1"
272+
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.2.1.tgz#04835fe9ab0d90ca2a93898cde2aa944c78c70bc"
273+
integrity sha512-DdQ1vps41JSyB2axyL1mBwJiXAPibgugIQPOmt0mL/yhwheQ6iuq2aKiJWgGWa9ldMfe3v9gIFYlrFgxQ5ThGQ==
269274
dependencies:
270275
"@octokit/core" "^3.2.3"
271276
"@octokit/plugin-paginate-rest" "^2.6.2"
272277
"@octokit/plugin-request-log" "^1.0.2"
273-
"@octokit/plugin-rest-endpoint-methods" "4.12.0"
278+
"@octokit/plugin-rest-endpoint-methods" "4.12.2"
274279

275-
"@octokit/types@6.10.0":
276-
version "6.10.0"
277-
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.10.0.tgz#243faa864b0955f574012d52e179de38ac9ebafe"
278-
integrity sha512-aMDo10kglofejJ96edCBIgQLVuzMDyjxmhdgEcoUUD64PlHYSrNsAGqN0wZtoiX4/PCQ3JLA50IpkP1bcKD/cA==
280+
"@octokit/types@6.10.1":
281+
version "6.10.1"
282+
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.10.1.tgz#5955dc0cf344bb82a46283a0c332651f5dd9f1ad"
283+
integrity sha512-hgNC5jxKG8/RlqxU/6GThkGrvFpz25+cPzjQjyiXTNBvhyltn2Z4GhFY25+kbtXwZ4Co4zM0goW5jak1KLp1ug==
279284
dependencies:
280285
"@octokit/openapi-types" "^5.1.0"
281286

282-
"@octokit/types@^6.0.3", "@octokit/types@^6.10.0", "@octokit/types@^6.11.0", "@octokit/types@^6.7.1":
287+
"@octokit/types@^6.0.3", "@octokit/types@^6.11.0", "@octokit/types@^6.7.1":
283288
version "6.12.2"
284289
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.12.2.tgz#5b44add079a478b8eb27d78cf384cc47e4411362"
285290
integrity sha512-kCkiN8scbCmSq+gwdJV0iLgHc0O/GTPY1/cffo9kECu1MvatLPh9E+qFhfRIktKfHEA6ZYvv6S1B4Wnv3bi3pA==
286291
dependencies:
287292
"@octokit/openapi-types" "^5.3.2"
288293

294+
"@octokit/types@^6.10.1":
295+
version "6.41.0"
296+
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.41.0.tgz#e58ef78d78596d2fb7df9c6259802464b5f84a04"
297+
integrity sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg==
298+
dependencies:
299+
"@octokit/openapi-types" "^12.11.0"
300+
289301
"@sheerun/mutationobserver-shim@^0.3.2":
290302
version "0.3.3"
291303
resolved "https://registry.yarnpkg.com/@sheerun/mutationobserver-shim/-/mutationobserver-shim-0.3.3.tgz#5405ee8e444ed212db44e79351f0c70a582aae25"

0 commit comments

Comments
 (0)