<p dir="auto">This is likely related to, or the same issue as these 3: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="653253994" data-permission-text="Title is private" data-url="https://github.com/denoland/deno/issues/6687" data-hovercard-type="issue" data-hovercard-url="/denoland/deno/issues/6687/hovercard" href="https://github.com/denoland/deno/issues/6687">#6687</a> <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="660616433" data-permission-text="Title is private" data-url="https://github.com/denoland/deno/issues/6802" data-hovercard-type="issue" data-hovercard-url="/denoland/deno/issues/6802/hovercard" href="https://github.com/denoland/deno/issues/6802">#6802</a> <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="646643098" data-permission-text="Title is private" data-url="https://github.com/denoland/deno/issues/6516" data-hovercard-type="issue" data-hovercard-url="/denoland/deno/issues/6516/hovercard" href="https://github.com/denoland/deno/issues/6516">#6516</a></p>
<p dir="auto">It appears that using compiler hints for types causes issues with bundle.</p>
<p dir="auto">Take this example:</p>
<p dir="auto">index.ts</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// @deno-types=&quot;./foo.d.ts&quot;
import * as Foo from './foo.js';

console.log(Foo.bar);"><pre class="notranslate"><span class="pl-c">// <span class="pl-k">@deno</span>-types="./foo.d.ts"</span>
<span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-smi">Foo</span> <span class="pl-k">from</span> <span class="pl-s">'./foo.js'</span><span class="pl-kos">;</span>

<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-smi">Foo</span><span class="pl-kos">.</span><span class="pl-c1">bar</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">foo.js</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export const bar = 'string';"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-s1">bar</span> <span class="pl-c1">=</span> <span class="pl-s">'string'</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">foo.d.ts</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export as namespace Foo;
export const bar: string;"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">as</span> <span class="pl-k">namespace</span> <span class="pl-smi">Foo</span><span class="pl-kos">;</span>
<span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-s1">bar</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">If I just do <code class="notranslate">deno run index.ts</code>  it runs without error.</p>
<p dir="auto">If I do <code class="notranslate">deno bundle index.ts app.js &amp;&amp; deno run app.js</code>, then I get this output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Bundle file:///home/mcpqndq/repos/typeHintTest/index.ts
Emit &quot;app.js&quot; (2.51 KB)
error: Uncaught TypeError: Cannot read property 'bar' of undefined
            console.log(Foo.bar);
                            ^
    at execute (file:///home/mcpqndq/repos/typeHintTest/app.js:112:29)
    at gExp (file:///home/mcpqndq/repos/typeHintTest/app.js:90:7)
    at __instantiate (file:///home/mcpqndq/repos/typeHintTest/app.js:97:27)
    at file:///home/mcpqndq/repos/typeHintTest/app.js:117:1"><pre class="notranslate"><code class="notranslate">Bundle file:///home/mcpqndq/repos/typeHintTest/index.ts
Emit "app.js" (2.51 KB)
error: Uncaught TypeError: Cannot read property 'bar' of undefined
            console.log(Foo.bar);
                            ^
    at execute (file:///home/mcpqndq/repos/typeHintTest/app.js:112:29)
    at gExp (file:///home/mcpqndq/repos/typeHintTest/app.js:90:7)
    at __instantiate (file:///home/mcpqndq/repos/typeHintTest/app.js:97:27)
    at file:///home/mcpqndq/repos/typeHintTest/app.js:117:1
</code></pre></div>
<p dir="auto">Not going to go through it of course, but removing the hint the error goes away.</p>
<p dir="auto"><a href="https://eslint.org/docs/rules/require-await" rel="nofollow">https://eslint.org/docs/rules/require-await</a></p>
<blockquote>
<p dir="auto">There is an eslint rule of <a href="https://eslint.org/docs/rules/require-await" rel="nofollow"><code class="notranslate">require-await</code></a> which would catch this as well. With TypeScript checking the return type it is very unlikely enforcing this would cause incorrect behaviour.</p>
</blockquote>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/kitsonk/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/kitsonk">@kitsonk</a> I did a quick check and we'd have to add a lot of supressions to tests (because there's a lot of mocks that assert async functions were called). I'm open to that change, but I'd open a new issue for that.</p>
<p dir="auto"><em>Originally posted by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/bartlomieju/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/bartlomieju">@bartlomieju</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="581746019" data-permission-text="Title is private" data-url="https://github.com/denoland/deno/issues/4384" data-hovercard-type="pull_request" data-hovercard-url="/denoland/deno/pull/4384/hovercard?comment_id=599469694&amp;comment_type=issue_comment" href="https://github.com/denoland/deno/pull/4384#issuecomment-599469694">#4384 (comment)</a></em></p>
<p dir="auto">A new rule "require-await" should be added to <code class="notranslate">.eslintrc.json</code>; then code in <code class="notranslate">core/</code>, <code class="notranslate">cli/</code> and <code class="notranslate">std/</code> should be linted accordingly.</p>