Skip to content

topLevelAwaits

Reports top-level await expressions in files that export values.

✅ This rule is included in the ts logicalStrict presets.

Top-level await (“TLA”) allows using await at the module level. While convenient for standalone files run like scripts, it can cause issues if those files are imported by other modules:

  • Modules using top-level await block their dependents until the await resolves
  • This can cause unexpected delays in application startup
  • It makes module loading order slower and sometimes less predictable
AEconsB0confAE = awai72impo5<3(sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4D./config.js1<1"sp ansty="le--0:#D6DEEB;--1:#403F">53<);d ivclassNa="meec-li">AEexport consB0apiUAE <= sp ansty="le--0:#D6DEEB;--1:#403F">53confA72apiU5<3;d ivclassNa="meco">AEconsB0daAE = awaiB0fet5<3(sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4D/api/da1<1"sp ansty="le--0:#D6DEEB;--1:#403F">5<3)sp ansty="le--0:#C792EA;--1:#8844">AB0th5<3(sp ansty="le--0:#D9F5DD;--1:#1111">1<1(sp ansty="le--0:#D7DBE0;--1:#403F">5<3rsp ansty="le--0:#D9F5DD;--1:#1111">1<1)sp ansty="le--0:#C792EA;--1:#8844">AE =<> sp ansty="le--0:#D6DEEB;--1:#403F">5 sp><3rsp ansty="le--0:#C792EA;--1:#8844">AB0js53()<);d ivclassNa="meec-li">AEexpo53 { data <};d ivclassNa="meco"><};d>
44AE3F53co64<4AE spans="tyle--0:#FFCB8B;--1:#11">1111Co3c44AEex344AEa344AEfunc361B0getCo11<11() spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">de443F<53 ( spans="tyle--0:#C792EA;--1:#88">4<4AE! spans="tyle--0:#D6DEEB;--1:#40">3F53confi3F53< spans="tyle--0:#D6DEEB;--1:#40">3F53con4<4AE= spans="tyle--0:#D6DEEB;--1:#40">344AEa36E72im31<111" spans="tyle--0:#ECC48D;--1:#98">4E4D./config.1<111" spans="tyle--0:#D6DEEB;--1:#40">3F<53) ;divclass="Nameec-">3F<53 spans="tyle--0:#D6DEEB;--1:#40">3de44AEre3F53 con3<}di vdivclass="Nameexpressive-">44AEex344AEa344AEfunc361B0fetch11<11() spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">de44AEre361B0f31<111" spans="tyle--0:#ECC48D;--1:#98">4E4D/api/1<111" spans="tyle--0:#D6DEEB;--1:#40">34<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B031<111( spans="tyle--0:#D7DBE0;--1:#40">31<111) spans="tyle--0:#D6DEEB;--1:#40">344 spans="tyle--0:#D6DEEB;--1:#40">3F><53 r spans="tyle--0:#C792EA;--1:#88">4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B03F53<()) ;divclass="Nameec-">3<);>

This rule is not configurable.

If you’re intentionally using top-level await for module initialization and understand the implications for module loading, you may disable this rule. You might consider using Flint disable comments and/or configuration file disables for those specific situations instead of completely disabling this rule.