Skip to content

fix: accept fs typed by @types/node 26 in the file system types - #700

Merged
alexander-akait merged 8 commits into
mainfrom
fix/fs-sync-types-node-26
Nov 3, 2026
Merged

alexander-akait merged 8 commits into
mainfrom
fix/fs-sync-types-node-26

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

@types/node 26 changed two sync methods:

  • fs.statSync: the { bigint: boolean } overload now takes throwIfNoEntry?: true (24 declared throwIfNoEntry?: false while returning Stats | BigIntStats, though false can return undefined).
  • fs.readFileSync: dropped the overload that accepted every kind of options at once (string | object | null | undefined).

Node's fs typed by 26 therefore no longer fits ReadFileSync, StatSync and LStatSync here. new CachedInputFileSystem(fs) fails to type-check for projects on @types/node 26, and webpack carries a @ts-expect-error on that line in NodeEnvironmentPlugin.

This PR:

  • StatSync/LStatSync: keeps only the overloads 24 and 26 agree on. The { bigint: true | false } forms now say throwIfNoEntry?: true, as 26 does. The { bigint: boolean } form is dropped, so such a call goes to the general overload, which includes undefined, as Node can when throwIfNoEntry is false.
  • ReadFileSync: its last overload takes a required options object, matching what both versions provide.
  • SyncAsyncFileSystemDecorator: it forwarded readFile/readFileSync options to fs.readFileSync as a single value of all kinds. It now hands null/undefined, an encoding string and an options object each to their own overload through a small readFileSyncWith helper. Each branch makes the same call as before, so behavior is unchanged.

Both directions type-check:

  • npm run lint:types and lint:types-test pass here, against @types/node 24.
  • With these types in webpack (@types/node 26), new CachedInputFileSystem(fs, 60000) is accepted. Once webpack's own StatSync drops the same { bigint: boolean } overload, the result is assignable to webpack's InputFileSystem and the suppression can go. That webpack change is ready and waits for this release.

Test

test/SyncAsyncFileSystemDecorator.test.js reads a fixture through readFileSync and readFile with no options, null, an encoding string and an options object, and checks the buffer or string for each.

Testing

  • npm run lint:code, lint:types, lint:types-test, fmt:check and lint:spellcheck pass.
  • All 1,640 tests pass, including the 5 new ones.


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Synchronous and callback-based file reads now handle supported encoding options consistently, including omitted options and null.
    • File metadata type definitions now clarify when results may be absent and when they return number- or bigint-based stats.
  • Compatibility
    • Filesystem type definitions support projects using @types/node 26.
    • Additional file-read option types are available through the filesystem decorator’s type declarations.

@types/node 26 changed fs.statSync and fs.readFileSync: the bigint: boolean
statSync overload now uses throwIfNoEntry?: true, and readFileSync dropped
the overload taking any options at once. Node's fs no longer fit
ReadFileSync, StatSync and LStatSync, so passing graceful-fs or fs to
CachedInputFileSystem failed to type-check.

Keep only the overloads @types/node 24 and 26 agree on, and have
SyncAsyncFileSystemDecorator hand each kind of options to its own
readFileSync overload instead of forwarding them as one value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh
@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.99%. Comparing base (19cfe1e) to head (5414625).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #700      +/-   ##
==========================================
+ Coverage   98.46%   98.99%   +0.52%     
==========================================
  Files          52       52              
  Lines       10908    10932      +24     
==========================================
+ Hits        10741    10822      +81     
+ Misses        167      110      -57     
Flag Coverage Δ
integration 98.99% <100.00%> (+0.52%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member Author

The two failing checks, benchmark (simulation) and benchmark (memory), are not caused by this PR. Both fail on Node 26.13.0 before any benchmark runs:

node: symbol lookup error: .../node_modules/@codspeed/core/prebuilds/linux-x64/node.napi.node: undefined symbol: _ZNK2v86String10Utf8LengthEPNS_7IsolateE

The prebuilt @codspeed/core add-on was compiled against a V8 API that Node 26 removed (v8::String::Utf8Length(Isolate*)). The same error fails the Benchmarks workflow on main (e.g. run 41404243699 at 19cfe1e). No fix exists yet. The options are a @codspeed/core release built for Node 26, or pinning the benchmark job to Node 24. Either belongs in its own PR, not this types change.


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2fde8790-a220-48c8-af7c-5472bd4a6f27
Commits

Reviewing files that changed from the base of the PR and between c291a9a and 5414625.

Files selected for processing: 4
  • .github/workflows/benchmarks.yml
  • lib/Resolver.js
  • test/SyncAsyncFileSystemDecorator.test.js
  • types/Resolver.d.ts
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 18f6e9df-a6e8-4705-b1cd-6263dd59faac
Commits

Reviewing files that changed from the base of the PR and between cfa51f7 and c291a9a.

Files selected for processing: 3
  • lib/Resolver.js
  • test/SyncAsyncFileSystemDecorator.test.js
  • types/Resolver.d.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

Walkthrough

Resolver filesystem overloads now specify read options and distinguish stat results by bigint and throwIfNoEntry values. SyncAsyncFileSystemDecorator routes synchronous and callback-style reads through readFileSyncWith. Its declarations add read-option types, and tests cover filesystem methods, option forms, missing paths, and optional methods.

Merge Risk: Low · previous review c291a

The new stat overloads can make bigint: true or bigint: false calls return a union type, which can break type-checking for consumers that rely on the narrower result. Moving the boolean overload after the literal overloads and regenerating the declarations fixes it. Nothing else blocks merging.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: updating filesystem types to accept fs typed by @types/node 26.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 5 files.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Comment thread lib/Resolver.js Resolved
Comment thread lib/Resolver.js Resolved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh
@changeset-bot

changeset-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5414625

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
enhanced-resolve Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

alexander-akait and others added 3 commits November 2, 2026 20:38
Node 26's statSync/lstatSync still return defined stats for
{ bigint: boolean } without throwIfNoEntry, so the overload stays
assignable from fs and keeps callers' results free of undefined.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh
fs.rmSync is missing on Node.js 12, which the test matrix still runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh
lts/* now resolves to Node.js 26, where the @codspeed/core native add-on
fails to load, so both benchmark jobs exit before measuring anything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh
(cherry picked from commit bd5a445)

Copy link
Copy Markdown
Member Author

The fix for the benchmark failure now exists: #701 pins the benchmark job to Node.js 24.22.0. I've ported it here as commit 62b9e33 so this PR's benchmarks can go green. Once #701 merges, that commit has no effect.


Generated by Claude Code

Comment thread lib/Resolver.js Resolved
alexander-akait and others added 3 commits November 2, 2026 20:46
TypeScript picks the first matching overload, so { bigint: true } and
{ bigint: false } widened to IStats | IBigIntStats while the boolean
overload came first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh
atimeNs only exists since Node.js 12.10, and the test matrix runs Node.js 10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh
The last main baseline ran on Node.js 24.21.0; measuring pull requests
on 24.22.0 shows runtime allocation changes as regressions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh
@codspeed

codspeed Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 14.16%

2 warnings, 1 note

⚠️ 5 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 4 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 1 improved benchmark
❌ 3 regressed benchmarks
✅ 138 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory alias-wildcard-scan: 100+1 wildcard + 1 exact 1.5 KB 2.7 KB -46.84%
❌ Memory node-compare: node require.resolve x 1000 50.5 KB 66.1 KB -23.68%
❌ CPU Simulation realistic-midsize: mixed batch (cold cache) 15.3 ms 18.1 ms -15.63%
⚡ Memory deep-package-subpath: pkg/a/b/c requests (warm) 3.5 KB 2.2 KB +58.6%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix/fs-sync-types-node-26 (5414625) with main (bc0e13f)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (19cfe1e) during the generation of this report, so bc0e13f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Copy link
Copy Markdown
Member Author

CodSpeed Performance Analysis is red on 5414625. The flagged results are runner noise, not caused by this PR:

  • The benchmarks now run on Node.js 24.21.0, the same version as the main baseline, so CodSpeed no longer flags a runtime difference. It still flags all 4 significant changes as measured on different hardware.
  • There are 3 regressions and 1 improvement (+58.6%), which is the pattern noise produces.
  • One "regression" is node-compare: node require.resolve x 1000. That benchmark measures Node's own resolver, so no change here can affect it.
  • The CPU-simulation "regression" (realistic-midsize: cold cache) is one CodSpeed itself marks as dominated by system calls, which it cannot simulate consistently.
  • This PR's runtime change is limited to how SyncAsyncFileSystemDecorator forwards readFileSync options. The rest is types and tests.

No code change can make this check green. A maintainer needs to acknowledge these results on CodSpeed, or main needs a fresh baseline once #701 lands.


Generated by Claude Code

@alexander-akait
alexander-akait merged commit 0b87b7e into main Nov 3, 2026
66 of 68 checks passed
@alexander-akait
alexander-akait deleted the fix/fs-sync-types-node-26 branch November 3, 2026 07:42
alexander-akait pushed a commit that referenced this pull request Nov 3, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## enhanced-resolve@5.26.1

### Patch Changes

- Accept `fs` typed by `@types/node` 26 in the file system types. (by
[@alexander-akait](https://github.com/alexander-akait) in
[#700](#700))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
alexander-akait added a commit to webpack/webpack that referenced this pull request Nov 3, 2026
…3100)

* fix: drop the NodeEnvironmentPlugin suppression for @types/node 26 fs

Needs the enhanced-resolve release with webpack/enhanced-resolve#700. Its
fs types then accept graceful-fs typed by @types/node 26, and webpack's
StatSync and LStatSync drop the same { bigint: boolean } overload, so the
CachedInputFileSystem is assignable without a suppression.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh

* fix: drop the enhanced-resolve suppressions for @types/node 26 fs

Bump enhanced-resolve to 5.26.1, whose file system types accept fs typed
by @types/node 26, so CachedInputFileSystem(fs) type-checks without
@ts-expect-error in NodeEnvironmentPlugin and the benchmark worker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh

* fix: keep the boolean bigint stat overload in the fs types

Match enhanced-resolve 5.26.1: { bigint: boolean } without throwIfNoEntry
returns defined stats, ordered after the literal true/false overloads so
those keep their exact result types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant