1/* @internal */ 2namespace ts.codefix { 3 registerCodeFix({ 4 errorCodes: [ 5 Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code, 6 Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code, 7 ], 8 getCodeActions: function getCodeActionsToAddEmptyExportDeclaration(context) { 9 const { sourceFile } = context; 10 const changes = textChanges.ChangeTracker.with(context, changes => { 11 const exportDeclaration = factory.createExportDeclaration( 12 /*modifiers*/ undefined, 13 /*isTypeOnly*/ false, 14 factory.createNamedExports([]), 15 /*moduleSpecifier*/ undefined 16 ); 17 changes.insertNodeAtEndOfScope(sourceFile, sourceFile, exportDeclaration); 18 }); 19 return [createCodeFixActionWithoutFixAll("addEmptyExportDeclaration", changes, Diagnostics.Add_export_to_make_this_file_into_a_module)]; 20 }, 21 }); 22}