Skip to content

namespaceDeclarations

Reports using legacy namespace declarations.

✅ This rule is included in the ts logical and logicalStrict presets.

Namespaces are a legacy feature of TypeScript that can lead to confusion and are not compatible with ECMAScript modules. Modern codebases generally use export and import statements to define and use ECMAScript modules instead.

AEnamespa53 Values< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEexport consB0valAE <= sp ansty="le--0:#F78C6C;--1:#AA09">821<23sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meec-li">5<3}d ivclassNa="meco"><}d>AEnamespa53 Fruits< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEexport consB0appAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4D<🍎 spans="tyle--0:#D9F5DD;--1:#11">1<111" spans="tyle--0:#D6DEEB;--1:#40">33<🍎">
<;}divstarlight-ta b-itemdat="aLabel✅">< Co rrectdivc="lassNameexpress"><-contentfi gcaptionc="lassNa">:#8844AEexpor:#3B6<1B0v alues="panstyle--0:#C792EA;--1">:#8<844A E = s="panstyle--0:#F78C6C;--1">:#A:<#40 3F53;divc="lass">< 12 3;divdivc="lassNameexpress"><-contentfi gcaptionc="lassNa">:#8844AEexpor:#3B61:#88<44A E = {divc="lassNam">:#<8844 AE s="panstyle--0:#C792EA;--1">:#8844A:<#111 111"s="panstyle--0:#ECC48D;--1">:#<984E 4D�="�spanstyle--0:#D9F5DD;-">-<1:#1 11111=""spanstyle--0:#C792EA;-">-<1:# 8844AE,di="vclassN">-<1:#8 844AE="}spanstyle--0:#D6DEEB;-">-<1:# 403F53;di="vcla"><: ">

Whether to allow namespaces declared with the declare keyword.

ts.rules({
namespaceDeclarations: {
allowDeclarations: true,
},
});
AEnamespa53 Values< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEexport consB0valAE <= sp ansty="le--0:#F78C6C;--1:#AA09">821<23sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meec-li">5<3}d ivclassNa="meco"><}d>
44AEdec344AEnames3F53 Valude44AEco61B0v64<4AE spans="tyle--0:#C5E478;--1:#3B">61B0nu33
ts.rules({
namespaceDeclarations: {
allowDefinitionFiles: true,
},
});

Whether to allow namespaces in .d.ts and other definition files.

leindex.AEdecla5<3 sp ansty="le--0:#C792EA;--1:#8844">AEnamespa53 Values< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEconsB0val7<2:sp ansty="le--0:#C792EA;--1:#8844">AB0numb5<3;d ivclassNa="meec-li">5<3}d ivclassNa="meco"><}d>
itleindex.44AEdec344AEnames3F53 Valude44AEco61B0v64<4AE spans="tyle--0:#C5E478;--1:#3B">61B0nu33

If your project uses TypeScript’s CommonJS export syntax (export = ...), you may need to use namespaces in order to export types from your module. You can learn more about this at:

If your project uses this syntax, either because it was architected before modern modules and namespaces, or because a module option such as verbatimModuleSyntax requires it, it may be difficult to migrate off of namespaces. In that case you may not be able to use this rule for parts of your project.

You might consider using Flint disable comments and/or configuration file disables for those specific situations instead of completely disabling this rule.