You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While a widen function can be useful for times where the return value isnt cared about, there are ways to avoid needing widen functions at all with a bit of explicit typing. This rule would prevent the use of any W function.
Example bad code:
pipe(O.some(1),O.foldW(// produces string | number without any sanity checks if thats actually wanted()=>"foo",(v)=>v+1;));
Example of good code:
pipe(O.some(1),O.fold((): string|number=>"foo",// Typing only needed here due to typescript's left to right type inference(v)=>v+1;));pipe(O.some(1),O.fold<number,string|number>(// This option requires the initial type too which is a bit redundant but still satisfies the rule()=>"foo",(v)=>v+1;));
The text was updated successfully, but these errors were encountered:
While a widen function can be useful for times where the return value isnt cared about, there are ways to avoid needing widen functions at all with a bit of explicit typing. This rule would prevent the use of any
W
function.Example bad code:
Example of good code:
The text was updated successfully, but these errors were encountered: