@@ -56,6 +56,9 @@ interface State {
5656 type ?: StartWorkType ;
5757 inWorktree ?: boolean ;
5858}
59+ interface StateWithType extends State {
60+ type : StartWorkType ;
61+ }
5962
6063export type StartWorkType = 'branch' | 'branch-worktree' | 'issue' | 'issue-worktree' ;
6164type StartWorkTypeItem = { type : StartWorkType ; inWorktree ?: boolean } ;
@@ -166,6 +169,7 @@ export class StartWorkCommand extends QuickCommand<State> {
166169 }
167170 }
168171
172+ assertsTypeStepState ( state ) ;
169173 const result = yield * this . pickIssueStep ( state , context , opened ) ;
170174 opened = true ;
171175 if ( result === StepResultBreak ) continue ;
@@ -399,7 +403,7 @@ export class StartWorkCommand extends QuickCommand<State> {
399403 }
400404
401405 private * pickIssueStep (
402- state : StepState < State > ,
406+ state : StepState < StateWithType > ,
403407 context : Context ,
404408 opened : boolean ,
405409 ) : StepResultGenerator < StartWorkItem | StartWorkTypeItem > {
@@ -523,7 +527,7 @@ export class StartWorkCommand extends QuickCommand<State> {
523527 private sendItemActionTelemetry (
524528 action : 'soft-open' ,
525529 item : StartWorkItem ,
526- state : StepState < State > ,
530+ state : StepState < StateWithType > ,
527531 context : Context ,
528532 ) {
529533 this . container . telemetry . sendEvent ( 'startWork/issue/action' , {
@@ -617,3 +621,12 @@ function getOpenOnWebQuickInputButton(integrationId: string): QuickInputButton |
617621 return undefined ;
618622 }
619623}
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