title: eslint - async arrow function return value error
body: <p>Currently experiencing a little bit of an annoyance rather than a problem. I have the following function:</p>
  <pre><code>export const getLoginSession = async (req: NextApiRequest): Promise&lt;undefined | User&gt; =&gt; {
    const token = getTokenCookie(req)
  
    if (!token) return
  
    const session = await Iron.unseal(token, TOKEN_SECRET, Iron.defaults)
    const expiresAt = session.createdAt + session.maxAge * 1000
  
    // Validate the expiration date of the session
    if (Date.now() &gt; expiresAt) {
      throw new Error('Session expired')
    }
  
    return session
  }
  </code></pre>
  <p>and <code>eslint(consistent-return)</code> is telling me: <code>Async arrow function expected no return value.</code></p>
  <p>I thought, why not try it like this instead:</p>
  <pre><code>export const getLoginSession = async (req: NextApiRequest): Promise&lt;undefined | User&gt; =&gt; {
    const token = getTokenCookie(req)
  
    if (token) {
      const session = await Iron.unseal(token, TOKEN_SECRET, Iron.defaults)
      const expiresAt = session.createdAt + session.maxAge * 1000
  
      if (Date.now() &gt; expiresAt) {
      throw new Error('Session expired')
      }
  
      return session
    }
  }
  </code></pre>
  <p>but then I am getting eslint's: <code>Expected to return a value at the end of async arrow function.</code></p>
  <p>A fix is to return to the first iteration and return <code>false</code> from <code>if (!token) return false</code> which fixes the problem.</p>
  <p>My question is</p>
  <ol>
  <li>is that the best way to handle it when we usually wouldn't explicitly return false?</li>
  <li>I am new to Typescript, is a return type of <code>Promise&lt;undefined | User&gt;</code> appropriate?</li>
  </ol>
  <p>type User contains id: string, username: string, etc...</p>