fix: correct isCancel type to narrow to CanceledError<T>#10952
Merged
jasonsaayman merged 4 commits intoMay 28, 2026
Conversation
… instead of Cancel
Contributor
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.isCancelin CommonJS typings to narrow toCanceledError<T>, matching ESM and runtime, and adds CJS typing tests to verify narrowing and that the genericTis preserved.Description
Use this section for review hints, explanations or discussion points.
index.d.ctstoisCancel<T = any>(value: any): value is CanceledError<T>;tsc --noEmitPRE_RELEASE_CHANGELOG.mdCancelor widenedanywas assumedDocs
Update
/docs/to showisCancelidentifiesCanceledErrorand keeps generic response types, with a short ESM and CJS example.Testing
Added
cjs-is-cancel-typing.tsand atypings.module.test.cjscase that compiles withtsc --noEmit, asserting both narrowing toCanceledErrorand genericTpreservation. 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