@@ -141,14 +141,14 @@ let takeUntil = (array: string[], startsWith: string): string[] => {
141141 return res ;
142142} ;
143143
144- export let findCodeActionsInDiagnosticsMessage = ( {
144+ export let findCodeActionsInDiagnosticsMessage = async ( {
145145 diagnostic,
146146 diagnosticMessage,
147147 file,
148148 range,
149149 addFoundActionsHere : codeActions ,
150150} : findCodeActionsConfig ) => {
151- diagnosticMessage . forEach ( ( line , index , array ) => {
151+ for ( const [ index , line ] of diagnosticMessage . entries ( ) ) {
152152 // Because of how actions work, there can only be one per diagnostic. So,
153153 // halt whenever a code action has been found.
154154 let codeActionExtractors = [
@@ -166,8 +166,8 @@ export let findCodeActionsInDiagnosticsMessage = ({
166166 let didFindAction = false ;
167167
168168 try {
169- didFindAction = extractCodeAction ( {
170- array,
169+ didFindAction = await extractCodeAction ( {
170+ array : diagnosticMessage ,
171171 codeActions,
172172 diagnostic,
173173 file,
@@ -183,7 +183,7 @@ export let findCodeActionsInDiagnosticsMessage = ({
183183 break ;
184184 }
185185 }
186- } ) ;
186+ }
187187} ;
188188
189189interface codeActionExtractorConfig {
@@ -196,12 +196,12 @@ interface codeActionExtractorConfig {
196196 codeActions : filesCodeActions ;
197197}
198198
199- type codeActionExtractor = ( config : codeActionExtractorConfig ) => boolean ;
199+ type codeActionExtractor = ( config : codeActionExtractorConfig ) => Promise < boolean > ;
200200
201201// This action extracts hints the compiler emits for misspelled identifiers, and
202202// offers to replace the misspelled name with the correct name suggested by the
203203// compiler.
204- let didYouMeanAction : codeActionExtractor = ( {
204+ let didYouMeanAction : codeActionExtractor = async ( {
205205 codeActions,
206206 diagnostic,
207207 file,
@@ -245,7 +245,7 @@ let didYouMeanAction: codeActionExtractor = ({
245245} ;
246246
247247// This action offers to wrap patterns that aren't option in Some.
248- let wrapInSome : codeActionExtractor = ( {
248+ let wrapInSome : codeActionExtractor = async ( {
249249 codeActions,
250250 diagnostic,
251251 file,
@@ -425,7 +425,7 @@ let handleUndefinedRecordFieldsAction = ({
425425// being undefined. We then offers an action that inserts all of the record
426426// fields, with an `assert false` dummy value. `assert false` is so applying the
427427// code action actually compiles.
428- let addUndefinedRecordFieldsV10 : codeActionExtractor = ( {
428+ let addUndefinedRecordFieldsV10 : codeActionExtractor = async ( {
429429 array,
430430 codeActions,
431431 diagnostic,
@@ -459,7 +459,7 @@ let addUndefinedRecordFieldsV10: codeActionExtractor = ({
459459 return false ;
460460} ;
461461
462- let addUndefinedRecordFieldsV11 : codeActionExtractor = ( {
462+ let addUndefinedRecordFieldsV11 : codeActionExtractor = async ( {
463463 array,
464464 codeActions,
465465 diagnostic,
@@ -508,7 +508,7 @@ let addUndefinedRecordFieldsV11: codeActionExtractor = ({
508508
509509// This action detects suggestions of converting between mismatches in types
510510// that the compiler tells us about.
511- let simpleConversion : codeActionExtractor = ( {
511+ let simpleConversion : codeActionExtractor = async ( {
512512 line,
513513 codeActions,
514514 file,
@@ -554,7 +554,7 @@ let simpleConversion: codeActionExtractor = ({
554554
555555// This action will apply a curried function (essentially inserting a dot in the
556556// correct place).
557- let applyUncurried : codeActionExtractor = ( {
557+ let applyUncurried : codeActionExtractor = async ( {
558558 line,
559559 codeActions,
560560 file,
@@ -608,7 +608,7 @@ let applyUncurried: codeActionExtractor = ({
608608
609609// This action detects missing cases for exhaustive pattern matches, and offers
610610// to insert dummy branches (using `failwith("TODO")`) for those branches.
611- let simpleAddMissingCases : codeActionExtractor = ( {
611+ let simpleAddMissingCases : codeActionExtractor = async ( {
612612 line,
613613 codeActions,
614614 file,
@@ -629,7 +629,7 @@ let simpleAddMissingCases: codeActionExtractor = ({
629629
630630 let filePath = fileURLToPath ( file ) ;
631631
632- let newSwitchCode = utils . runAnalysisAfterSanityCheck ( filePath , [
632+ let newSwitchCode = await utils . runAnalysisAfterSanityCheck ( filePath , [
633633 "codemod" ,
634634 filePath ,
635635 range . start . line ,
@@ -665,7 +665,7 @@ let simpleAddMissingCases: codeActionExtractor = ({
665665// This detects concrete variables or values put in a position which expects an
666666// optional of that same type, and offers to wrap the value/variable in
667667// `Some()`.
668- let simpleTypeMismatches : codeActionExtractor = ( {
668+ let simpleTypeMismatches : codeActionExtractor = async ( {
669669 line,
670670 codeActions,
671671 file,
0 commit comments