Skip to content

redundantTypeConstituents

Reports union and intersection type constituents that are redundant or override other types.

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

Some types can override other types in a union or intersection, making certain constituents redundant. TypeScript’s set theory of types includes cases where a constituent type might be useless in the parent union or intersection.

Within | unions:

  • any and unknown override all other union members
  • never is dropped from unions (except in return type position)
  • Primitive types like string override their literal types like "hello"

Within & intersections:

  • any and never override all other intersection members
  • unknown is dropped from intersections
  • Literal types like "hello" override their primitive types like string
AEty53 A5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0numb5<3 sp ansty="le--0:#7FDBCA;--1:#096E">7<2|sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0a5<3;d ivclassNa="meco">AEty53 A5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0stri5<3 sp ansty="le--0:#7FDBCA;--1:#096E">7<2|sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4Dliter1<1"sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco"><";d>AEty53 A5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0numb5<3 sp ansty="le--0:#7FDBCA;--1:#096E">7<2&sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0nev5<3;d ivclassNa="meco">AEty53 A5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0unkno5<3 sp ansty="le--0:#7FDBCA;--1:#096E">7<2&sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0stri5<3;d ivclassNa="meco">
44AE3F5<3 A spans="tyle--0:#C792EA;--1:#88">4<4AE= spans="tyle--0:#D6DEEB;--1:#40">361B0nu36361B0st3<;di vdivclass="Nameexpressive-">44AE3F5<3 B spans="tyle--0:#C792EA;--1:#88">4<4AE= spans="tyle--0:#D6DEEB;--1:#40">31<111" spans="tyle--0:#ECC48D;--1:#98">41<111" spans="tyle--0:#D6DEEB;--1:#40">3631<111" spans="tyle--0:#ECC48D;--1:#98">41<111" spans="tyle--0:#D6DEEB;--1:#40">3<"b"><;di vdivclass="Nameexpressive-">44AE3F5<3 C spans="tyle--0:#C792EA;--1:#88">4<4AE= spans="tyle--0:#D6DEEB;--1:#40">361B0nu36361B0ob3<;di vdivclass="Nameexpressive-">44AE3F5<3 D spans="tyle--0:#C792EA;--1:#88">4<4AE= spans="tyle--0:#D6DEEB;--1:#40">361B0st363F53 { b6361B0sy3F5<3 } ;divclass="Name">

This rule is not configurable.

Some projects choose to occasionally include a redundant type constituent for documentation purposes. For example, some unions intentionally include a redundant string in unions containing unknown to indicate intent. You might consider using Flint disable comments and/or configuration file disables for those specific situations instead of completely disabling this rule.