← Back to Pull requests

[typescript-axios] Fix generated package build on TypeScript 6 (types node, @types/node 20, ES5 range) #25599

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 09, 2026 14:28 UTC
Author

Fixes #25598 (regression introduced by #25148, shipped in 7.27.0).

Since 7.27.0 a typescript-axios client generated with npmName fails its npm install, because the prepare script now compiles with TypeScript 6 and the generated @types/node is never loaded (TypeScript 6 defaults types to an empty list):

api.ts(55,51): error TS2550: Property 'entries' does not exist on type 'ObjectConstructor'.
common.ts(19,38): error TS2591: Cannot find name 'url'. Do you need to install type definitions for node?

Changes

  • tsconfig.mustache: list "node" in types explicitly.

  • package.mustache: bump @types/node from 12.11.5 - 12.20.42 to ^20.0.0. @types/node 12 is incompatible with the TypeScript 6 standard library (DateTimeRangeFormatPart), and @types/node >= 16 needs TypeScript >= 4.9, so the lower bound of the typescript range follows (^4.9).

  • package.mustache: only include ^6.0 in the typescript range when supportsES6 is set. TypeScript 6 rejects target: ES5 unless ignoreDeprecations is "6.0", and TypeScript 5 rejects that value, so one generated tsconfig.json cannot serve both compilers for the ES5 target.

  • Samples: removed the hand-written custom.d.ts (declare module 'url';) from the petstore builds. It dates from the 2018 scaffold (#892), is not generated, and turns url into a shorthand ambient module, which breaks the @types/node 20 url typings (Cannot use namespace '_URL' as a type). Refreshed the three tracked package-lock.json files for the new ranges.

  • TypeScriptAxiosClientCodegenTest: extended the TypeScript 6 test and added one for the ES5 range.
  • Verification

    Compatibility matrix for the generated ES6 client with types: ["node"] (0 errors unless noted):

    | @types/node | TS 4.9.5 | TS 5.0.4 | TS 5.9.3 | TS 6.0.3 |
    |---|---|---|---|---|
    | 16 / 18 / 20 | ok | ok | ok | ok |
    | 22 | fails | fails | ok | ok |
    | 24 | fails | fails | ok | ok |

    @types/node 18 and 20 fail on TypeScript 4.0 and 4.6 (syntax errors in the typings), hence ^4.9.

  • npm install (which runs prepare -> tsc && tsc -p tsconfig.esm.json) succeeds in all regenerated samples with a package.json: es6-target (TypeScript 6.0.3 resolved, dist/ and dist/esm/), with-npm-version (5.9.3 from the refreshed lock), with-npm-version-and-separate-models-and-api (5.9.3), with-complex-headers (5.6.3), echo_api/build (5.6.3).

  • The minimal spec from #25598 (object query parameter + withNodeImports=true) compiles with TypeScript 6.0.3 after this change.

  • ./bin/generate-samples.sh ./bin/configs/typescript-axios-*.yaml regenerated the samples; only package.json and tsconfig.json changed.

  • ./mvnw -pl modules/openapi-generator -am -Dtest=TypeScriptAxiosClientCodegenTest -Dsurefire.failIfNoSpecifiedTests=false test: 16 tests, 0 failures.
  • Note: this branch is based on 0a5b61b1 because current master fails to compile (CSharpClientCodegen.postProcessAllModels is defined twice since #25593).

    PR checklist

  • Read the contribution guidelines.

  • Run the following to build the project and update samples:

  •   ./mvnw clean package || exit
      ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
      ./bin/utils/export_docs_generators.sh || exit
      

    Only the typescript-axios configs were regenerated; the change touches no other generator.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
  • @TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim

    <!-- This is an auto-generated description by cubic. -->
    ---

    Summary by cubic


    Fixes generated typescript-axios clients failing npm install when the prepare script resolves TypeScript 6, which no longer loads @types/node by default.

    Bug Fixes

  • Lists "node" explicitly in the generated tsconfig.json types so Object.entries and the url import compile under TypeScript 6.

  • Bumps @types/node from 12.11.5 - 12.20.42 to ^20.0.0 and raises the TypeScript range lower bound to ^4.9.

  • Excludes TypeScript 6 from the range for the ES5 target, since neither compiler accepts the other's ignoreDeprecations configuration for target: ES5.

  • Removes the hand-written declare module 'url' shim from petstore samples, which shadowed the @types/node 20 url typings.

  • Refreshes the affected sample package.json, tsconfig.json, and package-lock.json files and extends the codegen tests to cover both ranges.
  • <sup>Written for commit 185ede7bf5a2bb42bba056e6fb9fc57589f58f71. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/OpenAPITools/openapi-generator/pull/25599?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>

    <!-- End of auto-generated description by cubic. -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: thekhegay Review duration: 7091m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #25599"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%