<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by David Richey on Medium]]></title>
        <description><![CDATA[Stories by David Richey on Medium]]></description>
        <link>https://medium.com/@darichey?source=rss-5fee5a0ae64------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ay9JVcFa5E2zf5pb8cOu4Q.jpeg</url>
            <title>Stories by David Richey on Medium</title>
            <link>https://medium.com/@darichey?source=rss-5fee5a0ae64------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 01:22:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@darichey/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Flow can now detect unused Promises]]></title>
            <link>https://medium.com/flow-type/flow-can-now-detect-unused-promises-b49341256640?source=rss-5fee5a0ae64------2</link>
            <guid isPermaLink="false">https://medium.com/p/b49341256640</guid>
            <category><![CDATA[flowtype]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[David Richey]]></dc:creator>
            <pubDate>Mon, 10 Apr 2023 21:22:01 GMT</pubDate>
            <atom:updated>2023-04-10T21:29:52.596Z</atom:updated>
            <content:encoded><![CDATA[<p>As of v0.201.0, Flow can now lint against unused/floating Promises. Unused promises can be dangerous, because errors are potentially unhandled, and the code may not execute in the intended order. They are usually mistakes that Flow is perfectly positioned to warn you about.</p><p>A promise can be “used” by…</p><ul><li>awaiting it</li><li>Calling .then with a rejection handler (i.e., with two arguments)</li><li>Calling .catch</li><li>Calling .finally</li><li>Storing it in a variable, passing it to a function, etc.</li></ul><p>Some examples:</p><pre>// The promise returned by foo might fail<br>function foo(): Promise&lt;string&gt; {<br>  Math.random() &gt; 0.5<br>    ? Promise.resolve(&quot;example&quot;)<br>    : Promise.reject(new Error(&quot;error&quot;));<br>}<br><br>async function bar() {<br>  const x = foo(); // ok<br>  await foo(); // ok<br>  foo(); // error: `Promise` in async scope is unused. Did you mean to `await` it?<br>}<br><br>function baz() {<br>  baz(foo()); // ok<br>  foo().catch(e =&gt; /*...*/); // ok<br>  foo().then(s =&gt; /* ... */); // error: `Promise` in sync scope is unused. Promises must be handled by calling .then with a rejection handler, .catch, or .finally. <br>  foo(); // error<br>}</pre><h3>Fire-and-forget</h3><p>If you know it is safe to do so, you can explicitly ignore a promise using <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void">JavaScript’s void operator</a>. This has the same effect as suppressing the lint error.</p><pre>async function baz() {<br>  // I know what I&#39;m doing!<br>  void foo(); // ok<br>}</pre><h3>Quick fixes</h3><p>We have added two quick fixes to help fix errors raised by this lint:</p><ol><li>“Insert await” will transform foo() to await foo(). This is only suggested when in an async context.</li><li>“Insert void” will transform foo() to void foo().</li></ol><h3>Configuration</h3><p>The lint can be configured like any other in your project’s .flowconfig:</p><pre>[lints]<br>unused-promise=error</pre><p>See our <a href="https://flow.org/en/docs/linting/">linting documentation</a> for more information (by the way, a lot of our docs have recently been revamped, check it out!).</p><h3>Prior art</h3><p>The rules of this lint are the same as typescript-eslint’s no-floating-promises rule.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b49341256640" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flow-type/flow-can-now-detect-unused-promises-b49341256640">Flow can now detect unused Promises</a> was originally published in <a href="https://medium.com/flow-type">Flow</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>