Skip to content

fix(types): resolve type discrepancies between ESM and CJS TypeScript…#6956

Merged
jasonsaayman merged 3 commits intoaxios:v1.xfrom
jrnail23:type-discrepancies
Jul 16, 2025
Merged

fix(types): resolve type discrepancies between ESM and CJS TypeScript…#6956
jasonsaayman merged 3 commits intoaxios:v1.xfrom
jrnail23:type-discrepancies

Conversation

@jrnail23
Copy link
Contributor

@jrnail23 jrnail23 commented Jul 3, 2025

Resolves #6955

Reconciles type discrepancies between index.d.ts and index.d.cts.

@jasonsaayman jasonsaayman requested a review from Copilot July 6, 2025 15:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR aligns the CommonJS type definitions in index.d.cts with the ESM definitions by updating signatures and adding missing methods.

  • Broaden AxiosHeaderMatcher to accept string or RegExp
  • Add getSetCookie on AxiosHeaders and a static from factory on AxiosError
  • Fix InternalAxiosRequestConfig generic parameter and expose mergeConfig
Comments suppressed due to low confidence (4)

index.d.cts:9

  • The new AxiosHeaderMatcher signature omits the headers: RawAxiosHeaders parameter from the callback, which may break existing matchers that rely on access to all headers. Consider reintroducing that parameter or updating all downstream usage accordingly.
type AxiosHeaderMatcher = string | RegExp | ((this: AxiosHeaders, value: string, name: string) => boolean);

index.d.cts:80

  • Missing JSDoc comment for getSetCookie. Add a description explaining what the returned strings represent (e.g., parsed Set-Cookie header values) and any edge-case behavior.
  getSetCookie(): string[];

index.d.cts:102

  • No unit tests have been added for the new AxiosError.from factory method. Consider adding tests to verify that it correctly wraps different error inputs and preserves custom properties.
  static from<T = unknown, D = any>(

index.d.cts:555

  • The mergeConfig function is newly exposed but lacks documentation. Please add JSDoc explaining its merge strategy and sample usage to guide consumers.
    mergeConfig<D = any>(config1: AxiosRequestConfig<D>, config2: AxiosRequestConfig<D>): AxiosRequestConfig<D>;

Copy link
Member

@jasonsaayman jasonsaayman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good just the swap mentioned as most people do prefer any

@jasonsaayman jasonsaayman added this to the v1.11.0 milestone Jul 10, 2025
@jrnail23
Copy link
Contributor Author

looks good just the swap mentioned as most people do prefer any

@jasonsaayman, please see this comment:
#6956 (comment)

@jasonsaayman jasonsaayman self-requested a review July 15, 2025 18:19
@jasonsaayman jasonsaayman dismissed their stale review July 15, 2025 18:20

mistakenly mentioned an incorrect type

@jasonsaayman jasonsaayman merged commit 8517aa1 into axios:v1.x Jul 16, 2025
12 checks passed
@github-actions github-actions bot mentioned this pull request Jul 22, 2025
@github-actions
Copy link
Contributor

Hi, @jrnail23! This PR has been published in v1.11.0 release. Thank you for your contribution ❤️!

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.

Discrepancies between types from index.d.cts and index.d.ts

2 participants