@@ -56,6 +56,9 @@ interface State {
56
56
type ?: StartWorkType ;
57
57
inWorktree ?: boolean ;
58
58
}
59
+ interface StateWithType extends State {
60
+ type : StartWorkType ;
61
+ }
59
62
60
63
export type StartWorkType = 'branch' | 'branch-worktree' | 'issue' | 'issue-worktree' ;
61
64
type StartWorkTypeItem = { type : StartWorkType ; inWorktree ?: boolean } ;
@@ -166,6 +169,7 @@ export class StartWorkCommand extends QuickCommand<State> {
166
169
}
167
170
}
168
171
172
+ assertsTypeStepState ( state ) ;
169
173
const result = yield * this . pickIssueStep ( state , context , opened ) ;
170
174
opened = true ;
171
175
if ( result === StepResultBreak ) continue ;
@@ -399,7 +403,7 @@ export class StartWorkCommand extends QuickCommand<State> {
399
403
}
400
404
401
405
private * pickIssueStep (
402
- state : StepState < State > ,
406
+ state : StepState < StateWithType > ,
403
407
context : Context ,
404
408
opened : boolean ,
405
409
) : StepResultGenerator < StartWorkItem | StartWorkTypeItem > {
@@ -523,7 +527,7 @@ export class StartWorkCommand extends QuickCommand<State> {
523
527
private sendItemActionTelemetry (
524
528
action : 'soft-open' ,
525
529
item : StartWorkItem ,
526
- state : StepState < State > ,
530
+ state : StepState < StateWithType > ,
527
531
context : Context ,
528
532
) {
529
533
this . container . telemetry . sendEvent ( 'startWork/issue/action' , {
@@ -617,3 +621,12 @@ function getOpenOnWebQuickInputButton(integrationId: string): QuickInputButton |
617
621
return undefined ;
618
622
}
619
623
}
624
+
625
+ function assertsTypeStepState ( state : StepState < State > ) : asserts state is StepState < StateWithType > {
626
+ if ( state . type != null ) {
627
+ return ;
628
+ }
629
+
630
+ debugger ;
631
+ throw new Error ( 'Missing `item` field in state of StartWork' ) ;
632
+ }
0 commit comments