@@ -239,7 +239,7 @@ export class ReviewManager implements vscode.DecorationProvider {
239
239
private async validateState ( ) {
240
240
await this . _prManager . updateRepositories ( ) ;
241
241
242
- if ( this . _repository . state . HEAD === undefined ) {
242
+ if ( ! this . _repository . state . HEAD ) {
243
243
this . clear ( true ) ;
244
244
return ;
245
245
}
@@ -269,12 +269,12 @@ export class ReviewManager implements vscode.DecorationProvider {
269
269
Logger . appendLine ( `Review> current branch ${ this . _repository . state . HEAD . name } is associated with pull request #${ matchingPullRequestMetadata . prNumber } ` ) ;
270
270
this . clear ( false ) ;
271
271
this . _prNumber = matchingPullRequestMetadata . prNumber ;
272
- this . _lastCommitSha = null ;
272
+ this . _lastCommitSha = undefined ;
273
273
274
274
const { owner, repositoryName } = matchingPullRequestMetadata ;
275
275
const pr = await this . _prManager . resolvePullRequest ( owner , repositoryName , matchingPullRequestMetadata . prNumber ) ;
276
276
if ( ! pr ) {
277
- this . _prNumber = null ;
277
+ this . _prNumber = undefined ;
278
278
Logger . appendLine ( 'Review> This PR is no longer valid' ) ;
279
279
return ;
280
280
}
@@ -334,7 +334,7 @@ export class ReviewManager implements vscode.DecorationProvider {
334
334
335
335
private async replyToCommentThread ( document : vscode . TextDocument , range : vscode . Range , thread : vscode . CommentThread , text : string ) {
336
336
try {
337
- if ( this . _prManager . activePullRequest === null ) {
337
+ if ( ! this . _prManager . activePullRequest ) {
338
338
throw new Error ( 'Unable to find active pull request' ) ;
339
339
}
340
340
const matchedFile = this . findMatchedFileByUri ( document ) ;
@@ -381,11 +381,11 @@ export class ReviewManager implements vscode.DecorationProvider {
381
381
const query = uri . query === '' ? undefined : fromReviewUri ( uri ) ;
382
382
const isBase = query && query . base ;
383
383
384
- if ( matchedFile === null ) {
384
+ if ( ! matchedFile ) {
385
385
throw new Error ( `Cannot find document ${ uri . toString ( ) } ` ) ;
386
386
}
387
387
388
- if ( this . _lastCommitSha === null ) {
388
+ if ( ! this . _lastCommitSha ) {
389
389
throw new Error ( 'Last commit sha can not be null' ) ;
390
390
}
391
391
// git diff sha -- fileName
@@ -434,7 +434,7 @@ export class ReviewManager implements vscode.DecorationProvider {
434
434
435
435
private async editComment ( document : vscode . TextDocument , comment : vscode . Comment , text : string ) : Promise < void > {
436
436
try {
437
- if ( this . _prManager . activePullRequest === null ) {
437
+ if ( ! this . _prManager . activePullRequest ) {
438
438
throw new Error ( 'Unable to find active pull request' ) ;
439
439
}
440
440
@@ -470,7 +470,7 @@ export class ReviewManager implements vscode.DecorationProvider {
470
470
471
471
private async deleteComment ( document : vscode . TextDocument , comment : vscode . Comment ) : Promise < void > {
472
472
try {
473
- if ( this . _prManager . activePullRequest === null ) {
473
+ if ( ! this . _prManager . activePullRequest ) {
474
474
throw new Error ( 'Unable to find active pull request' ) ;
475
475
}
476
476
@@ -533,7 +533,7 @@ export class ReviewManager implements vscode.DecorationProvider {
533
533
const remote = branch . upstream ? branch . upstream . remote : null ;
534
534
if ( ! remote ) { return ; }
535
535
536
- if ( this . _prNumber === null || this . _prManager . activePullRequest === null ) {
536
+ if ( this . _prNumber === undefined || ! this . _prManager . activePullRequest ) {
537
537
return ;
538
538
}
539
539
@@ -1051,7 +1051,7 @@ export class ReviewManager implements vscode.DecorationProvider {
1051
1051
}
1052
1052
1053
1053
private async startDraft ( _document : vscode . TextDocument , _token : vscode . CancellationToken ) : Promise < void > {
1054
- if ( this . _prManager . activePullRequest === null ) {
1054
+ if ( ! this . _prManager . activePullRequest ) {
1055
1055
throw new Error ( 'Unable to find active pull request' ) ;
1056
1056
}
1057
1057
@@ -1065,7 +1065,7 @@ export class ReviewManager implements vscode.DecorationProvider {
1065
1065
}
1066
1066
1067
1067
private async deleteDraft ( _document : vscode . TextDocument , _token : vscode . CancellationToken ) {
1068
- if ( this . _prManager . activePullRequest === null ) {
1068
+ if ( ! this . _prManager . activePullRequest ) {
1069
1069
throw new Error ( 'Unable to find active pull request' ) ;
1070
1070
}
1071
1071
@@ -1111,7 +1111,7 @@ export class ReviewManager implements vscode.DecorationProvider {
1111
1111
}
1112
1112
1113
1113
private async finishDraft ( _document : vscode . TextDocument , _token : vscode . CancellationToken ) {
1114
- if ( this . _prManager . activePullRequest === null ) {
1114
+ if ( ! this . _prManager . activePullRequest ) {
1115
1115
throw new Error ( 'Unable to find active pull request' ) ;
1116
1116
}
1117
1117
@@ -1148,7 +1148,7 @@ export class ReviewManager implements vscode.DecorationProvider {
1148
1148
}
1149
1149
}
1150
1150
1151
- private findMatchedFileChange ( fileChanges : ( GitFileChangeNode | RemoteFileChangeNode ) [ ] , uri : vscode . Uri ) : GitFileChangeNode | null {
1151
+ private findMatchedFileChange ( fileChanges : ( GitFileChangeNode | RemoteFileChangeNode ) [ ] , uri : vscode . Uri ) : GitFileChangeNode | undefined {
1152
1152
let query = fromReviewUri ( uri ) ;
1153
1153
let matchedFiles = fileChanges . filter ( fileChange => {
1154
1154
if ( fileChange instanceof RemoteFileChangeNode ) {
@@ -1176,8 +1176,6 @@ export class ReviewManager implements vscode.DecorationProvider {
1176
1176
if ( matchedFiles && matchedFiles . length ) {
1177
1177
return matchedFiles [ 0 ] as GitFileChangeNode ;
1178
1178
}
1179
-
1180
- return null ;
1181
1179
}
1182
1180
1183
1181
public async switch ( pr : PullRequestModel ) : Promise < void > {
@@ -1281,10 +1279,10 @@ export class ReviewManager implements vscode.DecorationProvider {
1281
1279
} ) ;
1282
1280
}
1283
1281
1284
- private async getRemote ( potentialTargetRemotes : Remote [ ] , placeHolder : string , defaultUpstream ?: RemoteQuickPickItem ) : Promise < RemoteQuickPickItem | null > {
1282
+ private async getRemote ( potentialTargetRemotes : Remote [ ] , placeHolder : string , defaultUpstream ?: RemoteQuickPickItem ) : Promise < RemoteQuickPickItem | undefined > {
1285
1283
if ( ! potentialTargetRemotes . length ) {
1286
1284
vscode . window . showWarningMessage ( `No GitHub remotes found. Add a remote and try again.` ) ;
1287
- return null ;
1285
+ return ;
1288
1286
}
1289
1287
1290
1288
if ( potentialTargetRemotes . length === 1 && ! defaultUpstream ) {
@@ -1320,7 +1318,7 @@ export class ReviewManager implements vscode.DecorationProvider {
1320
1318
} ) ;
1321
1319
1322
1320
if ( ! selected ) {
1323
- return null ;
1321
+ return ;
1324
1322
}
1325
1323
1326
1324
return selected ;
@@ -1360,7 +1358,7 @@ export class ReviewManager implements vscode.DecorationProvider {
1360
1358
cancellable : false
1361
1359
} , async ( progress ) => {
1362
1360
progress . report ( { increment : 10 } ) ;
1363
- let HEAD : Branch | null = this . _repository . state . HEAD ! ;
1361
+ let HEAD : Branch | undefined = this . _repository . state . HEAD ! ;
1364
1362
const branchName = HEAD . name ;
1365
1363
1366
1364
if ( ! HEAD . upstream ) {
@@ -1411,8 +1409,8 @@ export class ReviewManager implements vscode.DecorationProvider {
1411
1409
}
1412
1410
1413
1411
if ( quitReviewMode ) {
1414
- this . _prNumber = null ;
1415
- this . _prManager . activePullRequest = null ;
1412
+ this . _prNumber = undefined ;
1413
+ this . _prManager . activePullRequest = undefined ;
1416
1414
1417
1415
if ( this . _statusBarItem ) {
1418
1416
this . _statusBarItem . hide ( ) ;
@@ -1432,7 +1430,7 @@ export class ReviewManager implements vscode.DecorationProvider {
1432
1430
}
1433
1431
}
1434
1432
1435
- async provideTextDocumentContent ( uri : vscode . Uri ) : Promise < string | null > {
1433
+ async provideTextDocumentContent ( uri : vscode . Uri ) : Promise < string | undefined > {
1436
1434
let { path, commit } = fromReviewUri ( uri ) ;
1437
1435
let changedItems = gitFileChangeNodeFilter ( this . _localFileChanges )
1438
1436
. filter ( change => change . fileName === path )
@@ -1471,8 +1469,6 @@ export class ReviewManager implements vscode.DecorationProvider {
1471
1469
1472
1470
return ret . join ( '\n' ) ;
1473
1471
}
1474
-
1475
- return null ;
1476
1472
}
1477
1473
1478
1474
dispose ( ) {
0 commit comments