Reports Promise catch callback parameters that are not typed as unknown.
✅ This rule is included in the ts logical and logicalStrict presets.
TypeScript’s useUnknownInCatchVariables compiler option only affects synchronous catch clauses, not Promise callbacks.
Promise rejection values can be anything, so the callback parameter in .catch() and the second argument to .then() should be typed as unknown to force proper type narrowing before use.
Without an explicit unknown type annotation, the catch callback parameter is implicitly typed as any, undermining type safety.
B0PromiAB0resol53<()sp ansty="le--0:#C792EA;--1:#8844">A()sp>B0cat5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1(sp ansty="le--0:#D7DBE0;--1:#403F">53err1(sp>1<1)sp ansty="le--0:#D6DEEB;--1:#403F">51)sp><3 sp ansty="le--0:#C792EA;--1:#8844">AE3 sp><=>sp ansty="le--0:#D6DEEB;--1:#403F">53=>sp>< {d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53conso sp>AB0l53(error {d><);d ivclassNa="meec-li">53});d><);d ivclassNa="meco"> { console.log(error);}"><);d>);d>);d>B0PromiAB0resol53<()sp ansty="le--0:#C792EA;--1:#8844">A()sp>B0cat5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1(sp ansty="le--0:#D7DBE0;--1:#403F">53err1(sp>7<2:sp ansty="le--0:#D6DEEB;--1:#403F">52:sp><3 sp ansty="le--0:#C5E478;--1:#3B61">B0a3 sp>1<1)sp ansty="le--0:#D6DEEB;--1:#403F">51)sp><3 sp ansty="le--0:#C792EA;--1:#8844">AE3 sp><=>sp ansty="le--0:#D6DEEB;--1:#403F">53=>sp>< {d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53conso sp>AB0l53(error {d><);d ivclassNa="meec-li">53});d><);d ivclassNa="meco"> { console.log(error);}"><);d>);d>);d>B0PromiAB0resol53<()sp ansty="le--0:#C792EA;--1:#8844">A()sp>B0th5<3(d ivclassNa="meec-li">nt< sp ansty="le--0:#D9F5DD;--1:#1111">11 sp><()sp ansty="le--0:#D6DEEB;--1:#403F">5()sp><3 sp ansty="le--0:#C792EA;--1:#8844">AE3 sp><=>sp ansty="le--0:#D6DEEB;--1:#403F">53 {=>sp>3(d><},d ivclassNa="meec-li">nt< sp ansty="le--0:#D9F5DD;--1:#1111">1 sp><1(sp ansty="le--0:#D7DBE0;--1:#403F">53err1(sp>1<1)sp ansty="le--0:#D6DEEB;--1:#403F">51)sp><3 sp ansty="le--0:#C792EA;--1:#8844">AE3 sp><=>sp ansty="le--0:#D6DEEB;--1:#403F">53=>sp>},d>< {d ivclassNa="meec-li">53 < sp ansty="le--0:#D6DEEB;--1:#403F">53conso sp>AB0l53(error {d><);d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53 sp>);d><},d ivclassNa="meec-li">53},d><);d ivclassNa="meco"> {}, (error) => { console.log(error); },"><);d>);d>);d> 61B0Pro4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0res4AE.>3F<53() spans="tyle--0:#C792EA;--1:#88">453()><4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0c4AE.>31<111( spans="tyle--0:#D7DBE0;--1:#40">3F53e111(>6361B0unk1<111) spans="tyle--0:#D6DEEB;--1:#40">3111)>44 spans="tyle--0:#D6DEEB;--1:#40">3F><53 {divclass="Nameec-">de443F53 (er44AEinstan31111E3F553 ><3) {divclass="Nameec-">3F53< spans="tyle--0:#D6DEEB;--1:#40">3F53con >4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B4AE.><0log spans="tyle--0:#D6DEEB;--1:#40">3F53(e0log>4<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72mes4AE.>3F3) ><53) ;divclass="Nameec-">3F<53 spans="tyle--0:#D6DEEB;--1:#40">353 >53)>3F5<3}) ;divclass="Name"> { if (error instanceof Error) { console.log(error.message); }"><})>})>3})><;di vdivclass="Nameexpressive-">61B0Pro4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0res4AE.>3F<53() spans="tyle--0:#C792EA;--1:#88">453()><4AE. spans="tyle--0:#82AAFF;--1:#3B">61B04AE.>3de11<11() spans="tyle--0:#D6DEEB;--1:#40">311()>44 spans="tyle--0:#D6DEEB;--1:#40">3F53>< {} ,divclass="Nameec-">de1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53e111(>6361B0unk1<111) spans="tyle--0:#D6DEEB;--1:#40">3111)>44 spans="tyle--0:#D6DEEB;--1:#40">3F> {}><53 {divclass="Nameec-">3F53< spans="tyle--0:#D6DEEB;--1:#40">3F53con >4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B4AE.><0log spans="tyle--0:#D6DEEB;--1:#40">3F53(err0log>53 >3F<53 spans="tyle--0:#D6DEEB;--1:#40">3F53 ><53} ,divclass="Nameec-">3F53}><53) ;divclass="Name"> {}, (error: unknown) => { console.log(error); }"><,)>,)>53)>;di><;di vdivclass="Nameexpressive-">61B0Pro4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0res4AE.>3F<53() spans="tyle--0:#C792EA;--1:#88">453()><4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0c4AE.>311<11() spans="tyle--0:#D6DEEB;--1:#40">311()>44 spans="tyle--0:#D6DEEB;--1:#40">3F><53 {divclass="Nameec-">3F<53 spans="tyle--0:#D6DEEB;--1:#40">3F53con53 >4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B4AE.><0log spans="tyle--0:#D6DEEB;--1:#40">30log>1<111" spans="tyle--0:#ECC48D;--1:#98">4E4Derror occu111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111">53 ><53) ;divclass="Nameec-">3F553)><3}) ;divclass="Name"> { console.log("error occurred");"><})>})>3})>;di>
This rule is not configurable.
If your codebase is not yet able to enable useUnknownInCatchVariables, it may be similarly difficult to enable this rule.
If you have modified the global type declarations to make then() and catch() callbacks use the unknown type without an explicit type annotation, you do not need this rule.