<p dir="auto">This bug is likely a very close sibling of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="655500419" data-permission-text="Title is private" data-url="https://github.com/facebook/react/issues/19327" data-hovercard-type="issue" data-hovercard-url="/facebook/react/issues/19327/hovercard" href="https://github.com/facebook/react/issues/19327">#19327</a>, only this time it is for casting <code class="notranslate">as T</code>. I can't understand the line that fixed it (<a href="https://github.com/facebook/react/pull/19316/files#diff-26e3db67655052fb708395a89179543bR546-R549">this specifically</a>), but am happy to help write the rest of the PR's tests if someone can help with the fix for this one.</p>
<p dir="auto">React version: 16.13.1 (latest)<br>
eslint-plugin-react-hooks version: 4.1.0 (latest)</p>
<h2 dir="auto">Steps To Reproduce</h2>
<ol dir="auto">
<li>Cast a variable to a type in a hook callback.</li>
</ol>
<p dir="auto">Link to code example:<br>
<a href="https://codesandbox.io/s/admiring-tharp-cbq0d?file=/src/App.tsx" rel="nofollow">https://codesandbox.io/s/admiring-tharp-cbq0d?file=/src/App.tsx</a></p>
<div class="highlight highlight-source-tsx notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="type Foo = &quot;Bar&quot;;

export default function App() {
  const callback = React.useCallback(() =&gt; {
    // this is the offending line:
    const foo = &quot;Foo&quot; as Foo;
    return foo;
  }, []);
  return &lt;div onClick={callback} /&gt;;
}"><pre class="notranslate"><span class="pl-k">type</span> <span class="pl-smi">Foo</span> <span class="pl-c1">=</span> <span class="pl-s">"Bar"</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-k">function</span> <span class="pl-smi">App</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">const</span> <span class="pl-s1">callback</span> <span class="pl-c1">=</span> <span class="pl-smi">React</span><span class="pl-kos">.</span><span class="pl-en">useCallback</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-c">// this is the offending line:</span>
    <span class="pl-k">const</span> <span class="pl-s1">foo</span> <span class="pl-c1">=</span> <span class="pl-s">"Foo"</span> <span class="pl-k">as</span> <span class="pl-smi">Foo</span><span class="pl-kos">;</span>
    <span class="pl-k">return</span> <span class="pl-s1">foo</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">return</span> <span class="pl-c1">&lt;</span><span class="pl-ent">div</span> <span class="pl-c1">onClick</span><span class="pl-c1">=</span><span class="pl-kos">{</span><span class="pl-s1">callback</span><span class="pl-kos">}</span> <span class="pl-c1">/</span><span class="pl-c1">&gt;</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<h2 dir="auto">The current behavior</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="React Hook React.useCallback has a missing dependency: 'Foo'. Either include it or remove the dependency array.eslintreact-hooks/exhaustive-deps"><pre class="notranslate"><code class="notranslate">React Hook React.useCallback has a missing dependency: 'Foo'. Either include it or remove the dependency array.eslintreact-hooks/exhaustive-deps
</code></pre></div>
<h2 dir="auto">The expected behavior</h2>
<p dir="auto">No error, a type cannot be a dependency.</p>
<p dir="auto">Describe what you were doing when the bug occurred:<br>
1.<br>
2.<br>
3.</p>
<hr>
<h2 dir="auto">Please do not remove the text below this line</h2>
<p dir="auto">DevTools version: 4.13.0-2a7bb41548</p>
<p dir="auto">Call stack: at store_Store.getElementAtIndex (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:22067:35)<br>
at store_Store.getElementIDAtIndex (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:22083:26)<br>
at chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:29665:63<br>
at List.render (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:23789:18)<br>
at Hi (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:13937:76)<br>
at Gi (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:13928:10)<br>
at uk (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:16676:86)<br>
at tk (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:16193:11)<br>
at qk (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:16185:23)<br>
at jk (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:16169:5)</p>
<p dir="auto">Component stack: at List (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:23484:30)<br>
at div<br>
at AutoSizer (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:3642:5)<br>
at div<br>
at div<br>
at Tree_Tree (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:29426:47)<br>
at div<br>
at div<br>
at OwnersListContextController (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:28575:3)<br>
at SettingsModalContextController (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:29016:3)<br>
at Components_Components (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:34836:52)<br>
at ErrorBoundary_ErrorBoundary (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:30336:5)<br>
at PortaledContent (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:30416:5)<br>
at div<br>
at div<br>
at ProfilerContextController (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:34462:3)<br>
at TreeContextController (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:25252:3)<br>
at SettingsContextController (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:25855:3)<br>
at ModalDialogContextController (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:30558:3)<br>
at DevTools_DevTools (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/main.js:37572:3)</p>