Repository navigation
Conversation
Calling the fs.Stats constructor directly, with or without new, now throws ERR_ILLEGAL_CONSTRUCTOR. fs.Stats instances are only created internally. The class remains exported from node:fs so that instanceof checks continue to work. Internally, instances are constructed through a private symbol. This has been a runtime deprecation since v22.0.0. Refs: nodejs#52067 Refs: nodejs#51879 Assisted-by: Claude Signed-off-by: James M Snell <jasnell@gmail.com>
|
Review requested:
|
Co-authored-by: James M Snell <jasnell@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67491 +/- ##
==========================================
- Coverage 90.67% 90.65% -0.02%
==========================================
Files 799 799
Lines 280245 280249 +4
Branches 54125 54114 -11
==========================================
- Hits 254100 254068 -32
- Misses 16280 16291 +11
- Partials 9865 9890 +25
🚀 New features to boost your workflow:
|
|
@nodejs/tsc ... will need another sign off here |
LiviaMedeiros
left a comment
There was a problem hiding this comment.
I think this shouldn't land until we have better alternative (e.g. fs.isStats()) to instanceof Stats that we can recommend in the docs, or make such instanceof work with BigIntStats as well.
| for public use. The class remains exported, so `instanceof fs.Stats` checks | ||
| continue to work. |
There was a problem hiding this comment.
This recommendation doesn't look correct, because
fs.statSync('/etc/hosts') instanceof fs.Stats === true
// however:
fs.statSync('/etc/hosts', { bigint: true }) instanceof fs.Stats === false
// and:
fs.BigIntStats === undefinedThere was a problem hiding this comment.
The Stats/BigIntStats duality has always been a mess. I wonder if it's time to consolidate the Stats interface by having both millisecond properties as numbers and nanosecond properties as bigints, and deprecate BigIntStats altogether...
Calling the fs.Stats constructor directly, with or without new, now throws ERR_ILLEGAL_CONSTRUCTOR. fs.Stats instances are only created internally.
The class remains exported from node:fs so that instanceof checks continue to work. Internally, instances are constructed through a private symbol.
This has been a runtime deprecation since v22.0.0.
Refs: #52067
Refs: #51879