fix(types): align FetchError.errno with NodeJS ErrnoException#1875
fix(types): align FetchError.errno with NodeJS ErrnoException#1875nthbotast wants to merge 1 commit into
Conversation
rsbasic
left a comment
There was a problem hiding this comment.
Review: APPROVE (types only, LOW risk)
Changes FetchError.errno type from string to NodeJS.ErrnoException['errno']. This is a type-level correction — no runtime code changes.
The current type (errno?: string) is inaccurate. Node.js ErrnoException.errno is number | undefined, not string. The existing type lets TypeScript users write code like if (err.errno === 'ECONNREFUSED') which compiles but is incorrect at runtime — errno is a numeric system error code, not a string error name. That is what err.code is for.
The test file change (throw new TypeError(error.errno as string | undefined) → throw new TypeError(String(error.errno))) is consistent — it no longer assumes errno is a string.
One consideration: This is technically a breaking change for TypeScript consumers who currently compare errno to string values. Those comparisons are already wrong at runtime (they would never match), so fixing the type surfaces existing bugs rather than introducing new ones.
Verdict: Safe to merge. Corrects a type inaccuracy that masks real bugs.
Summary
FetchError.errnotype fromstringtoNodeJS.ErrnoException['errno']ErrnoExceptioncontractCloses #1831
Validation
git diff --cached --checknpm run test-typescurrently fails in this ephemeral environment due to@types/node/http2.d.tsparser/type errors (toolchain mismatch), unrelated to this patch