fix: correct isCancel type to narrow to CanceledError by Mohammad-Faiz-Cloud-Engineer · Pull Request #10952 · axios/axios (original) (raw)

The isCancel type guard in index.d.cts was returning value is Cancel which doesn't match the actual runtime isCancel checks for CanceledError, not Cancel. This updates it to value is CanceledError so TypeScript correctly narrows the type when using the guard.


Summary by cubic

Fixes axios.isCancel in CommonJS typings to narrow to CanceledError<T>, matching ESM and runtime, and adds CJS typing tests to verify narrowing and that the generic T is preserved.

Description

Use this section for review hints, explanations or discussion points.

Docs

Update /docs/ to show isCancel identifies CanceledError and keeps generic response types, with a short ESM and CJS example.

Testing

Added cjs-is-cancel-typing.ts and a typings.module.test.cjs case that compiles with tsc --noEmit, asserting both narrowing to CanceledError and generic T preservation. No runtime tests needed.

Semantic version impact

Patch: declaration fix aligning CommonJS types with existing runtime and ESM behavior.

Written for commit 4b89869. Summary will update on new commits.

Review in cubic