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: context => { 9 const { sourceFile } = context; 10 const changes = textChanges.ChangeTracker.with(context, changes => { 11 const exportDeclaration = factory.createExportDeclaration( 12 /*decorators*/ undefined, 13 /*modifiers*/ undefined, 14 /*isTypeOnly*/ false, 15 factory.createNamedExports([]), 16 /*moduleSpecifier*/ undefined 17 ); 18 changes.insertNodeAtEndOfScope(sourceFile, sourceFile, exportDeclaration); 19 }); 20 return [createCodeFixActionWithoutFixAll("addEmptyExportDeclaration", changes, Diagnostics.Add_export_to_make_this_file_into_a_module)]; 21 }, 22 }); 23}