topLevelVar
- Type:
optionaltopLevelVar:boolean
Defined in: options/output-options.ts:632
Whether to use var declarations at the top level scope instead of function / class / let / const expressions.
Enabling this option can improve runtime performance of the generated code in certain environments.
Default
false
In-depth
Multiple JavaScript engines have had and continue to have performance issues with Temporal dead zone (TDZ) checks. These checks validate that a let, const, or class symbol isn't used before it's initialized.
Related issues:
- V8: https://issues.chromium.org/issues/42203665
- JavaScriptCore: https://bugs.webkit.org/show_bug.cgi?id=199866 (fixed)