<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto">As <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/fs/promises.d.ts#L611">defined in TypeScript</a>, the <code class="notranslate">fs.stat</code> in Node.js returns value of type <code class="notranslate">Stats | BigIntStats</code>. While in Webpack's type definition, the API <code class="notranslate">InputFileSystem.stat</code> <a href="https://github.com/webpack/webpack/blob/51637ae59b4ec8a7e38d4ecde22fee93f6176935/types.d.ts#L4356-L4382">returns value of type <code class="notranslate">IStats</code></a>, which is not assignable to <code class="notranslate">Stats | BigIntStats</code>.</p>
<p dir="auto">This becomes a problem for me. I'm using <code class="notranslate">fast-glob</code>, and its <code class="notranslate">sync</code> API offers an <code class="notranslate">fs</code> option. However, I can't assign the <code class="notranslate">LoaderContext.fs</code> to this option.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>
<p dir="auto">Create index.ts with the following content:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { sync } from 'fast-glob'
import { LoaderContext } from 'webpack';

function testFunc(fs: LoaderContext&lt;any&gt;['fs']) {
    sync('source', { fs: {
        stat: fs.stat
    } });
}"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">sync</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'fast-glob'</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-smi">LoaderContext</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'webpack'</span><span class="pl-kos">;</span>

<span class="pl-k">function</span> <span class="pl-en">testFunc</span><span class="pl-kos">(</span><span class="pl-s1">fs</span>: <span class="pl-smi">LoaderContext</span><span class="pl-kos">&lt;</span><span class="pl-smi">any</span><span class="pl-kos">&gt;</span><span class="pl-kos">[</span><span class="pl-s">'fs'</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-en">sync</span><span class="pl-kos">(</span><span class="pl-s">'source'</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">fs</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">stat</span>: <span class="pl-s1">fs</span><span class="pl-kos">.</span><span class="pl-c1">stat</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></pre></div>
<p dir="auto">And compile with tsc:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="➜  tsc index.ts
index.ts:6:9 - error TS2769: No overload matches this call.
  Overload 1 of 2, '(source: string | string[], options: Options &amp; EntryObjectPredicate): Entry[]', gave the following error.
    Type '(arg0: string, arg1: (arg0?: ErrnoException, arg1?: IStats) =&gt; void) =&gt; void' is not assignable to type 'StatAsynchronousMethod'.
      Types of parameters 'arg1' and 'callback' are incompatible.
        Types of parameters 'stats' and 'arg1' are incompatible.
          Type 'IStats' is not assignable to type 'Stats | BigIntStats'.
            Type 'IStats' is not assignable to type 'BigIntStats'.
              Property 'atimeNs' is optional in type 'IStats' but required in type 'BigIntStats'.
  Overload 2 of 2, '(source: string | string[], options?: Options): string[]', gave the following error.
    Type '(arg0: string, arg1: (arg0?: ErrnoException, arg1?: IStats) =&gt; void) =&gt; void' is not assignable to type 'StatAsynchronousMethod'.

6         stat: fs.stat
          ~~~~

  node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts:8:5
    8     stat: StatAsynchronousMethod;
          ~~~~
    The expected type comes from property 'stat' which is declared here on type 'Partial&lt;FileSystemAdapter&gt;'
  node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts:8:5
    8     stat: StatAsynchronousMethod;
          ~~~~
    The expected type comes from property 'stat' which is declared here on type 'Partial&lt;FileSystemAdapter&gt;'


Found 1 error."><pre class="notranslate"><code class="notranslate">➜  tsc index.ts
index.ts:6:9 - error TS2769: No overload matches this call.
  Overload 1 of 2, '(source: string | string[], options: Options &amp; EntryObjectPredicate): Entry[]', gave the following error.
    Type '(arg0: string, arg1: (arg0?: ErrnoException, arg1?: IStats) =&gt; void) =&gt; void' is not assignable to type 'StatAsynchronousMethod'.
      Types of parameters 'arg1' and 'callback' are incompatible.
        Types of parameters 'stats' and 'arg1' are incompatible.
          Type 'IStats' is not assignable to type 'Stats | BigIntStats'.
            Type 'IStats' is not assignable to type 'BigIntStats'.
              Property 'atimeNs' is optional in type 'IStats' but required in type 'BigIntStats'.
  Overload 2 of 2, '(source: string | string[], options?: Options): string[]', gave the following error.
    Type '(arg0: string, arg1: (arg0?: ErrnoException, arg1?: IStats) =&gt; void) =&gt; void' is not assignable to type 'StatAsynchronousMethod'.

6         stat: fs.stat
          ~~~~

  node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts:8:5
    8     stat: StatAsynchronousMethod;
          ~~~~
    The expected type comes from property 'stat' which is declared here on type 'Partial&lt;FileSystemAdapter&gt;'
  node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts:8:5
    8     stat: StatAsynchronousMethod;
          ~~~~
    The expected type comes from property 'stat' which is declared here on type 'Partial&lt;FileSystemAdapter&gt;'


Found 1 error.
</code></pre></div>






<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">The code snippet above should compile without any type errors.</p>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  5.50.0<br>
Node.js version: 14.15.1<br>
Operating System: macOS Big Sur 11.5.2<br>
Additional tools:</p>
<p dir="auto"><g-emoji class="g-emoji" alias="christmas_tree" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f384.png">🎄</g-emoji> First, thanks for trying and giving feedback to our alpha version. <g-emoji class="g-emoji" alias="christmas_tree" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f384.png">🎄</g-emoji></p>
<p dir="auto">Note that it's still in an early state and stuff may be broken. This is something you want to report here, as we don't want this to happen in the final release.</p>
<p dir="auto">Note that the major version has breaking changes and some plugins might no longer work as expected. We try to provided compatibility layers when possible, but some of the changes make this difficult (especially regarding injection additional runtime code). If some plugin isn't working this is also something you should report here to we are at least aware of it and may work on fixing it or adding a compatibility layer.</p>
<p dir="auto">Here is the full <a href="https://github.com/webpack/changelog-v5/blob/master/README.md">Changelog</a>. Make sure to read at least until the configuration changes to be up-to-date.</p>
<p dir="auto">If you find something missing in the changelog, this is also something to report here. Easy fixes can made directly in the repo. Every webpack contributor has write access, otherwise send a PR.</p>
<p dir="auto">If everything is working great, that's also nice to hear. If you are trying the Persistent Caching feature, we would love to see numbers.</p>
<p dir="auto">Please make sure to try with the lastest alpha version before reporting, as it may already be fixed. You can use the npm dist-tag <code class="notranslate">next</code> to reference the latest alpha version.</p>
<p dir="auto"><code class="notranslate">package.json</code> <code class="notranslate">"webpack": "next"</code>. Update with <code class="notranslate">yarn upgrade webpack</code> / <code class="notranslate">npm update webpack</code>.</p>
<p dir="auto">Not to forget: Thanks for everybody contributed to this version (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/byzyk/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/byzyk">@byzyk</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/cacheflow/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/cacheflow">@cacheflow</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/Connormiha/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/Connormiha">@Connormiha</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/fscherwi/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/fscherwi">@fscherwi</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/guybedford/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/guybedford">@guybedford</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/michael-ciniawsky/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/michael-ciniawsky">@michael-ciniawsky</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/niieani/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/niieani">@niieani</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ooflorent/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ooflorent">@ooflorent</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/SevInf/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/SevInf">@SevInf</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/smelukov/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/smelukov">@smelukov</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/sodatea/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/sodatea">@sodatea</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/sokra/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/sokra">@sokra</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/xtuc/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/xtuc">@xtuc</a>). <g-emoji class="g-emoji" alias="tada" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f389.png">🎉</g-emoji></p>
<hr>
<p dir="auto">Feedback summary:</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> mini-css-extract-plugin is incompatible (RuntimeModules change)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> fork-ts-checker-webpack-plugin is incompatible (frozen hooks)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> circular-dependency-plugin is incompatible (dep.module removed)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> cache-loader is no longer needed</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> webpack-cli misses <code class="notranslate">Stats.presetToOptions</code> (should use <code class="notranslate">compilation.createStatsOptions</code>)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> html-webpack-plugin misses <code class="notranslate">fileTimestamps</code> (should use <code class="notranslate">fileSystemInfo</code>)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> null prototype objects can't be serialized</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Deprecation warning for the HMR defaults</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Docs need update</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <code class="notranslate">namedChunkGroups</code> have weird keys</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <code class="notranslate">MultiStats.toJson</code> fails without options argument (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="394358326" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/8561" data-hovercard-type="pull_request" data-hovercard-url="/webpack/webpack/pull/8561/hovercard" href="https://github.com/webpack/webpack/pull/8561">#8561</a>)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Stats assetsByChunkName is different to v4</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <code class="notranslate">node.global: false</code> causes many errors</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <code class="notranslate">define</code> is missing require requirement for <code class="notranslate">module</code></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> reasons for scope-hoisted modules are inconsistent</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> resolve.alias false doesn't work</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Source map caching is very slow</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Runtime modules duplicated in runtime chunk single</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> <code class="notranslate">Compilation.rebuildModule</code> broken in alpha</li>
</ul>