Repository navigation
Conversation
Since OpenAPITools#25148 the generated devDependency range admits TypeScript 6, which npm now resolves. TypeScript 6 no longer loads every package under node_modules/@types by default, so the generated @types/node was never loaded: Object.entries (ES2017, only available through @types/node with target ES6) and the "url" import of withNodeImports failed to compile. - tsconfig: list "node" in "types" explicitly. - package.json: bump @types/node to ^20 (12.x is incompatible with the TypeScript 6 standard library). @types/node >= 16 requires TypeScript 4.9, so the lower bound of the range follows. - package.json: keep TypeScript 6 out of the range when the target is ES5. TypeScript 6 only accepts target ES5 with ignoreDeprecations "6.0", a value TypeScript 5 rejects, so a single tsconfig cannot serve both. - samples: drop the manual custom.d.ts shim (declare module 'url'), which turns the module into a shorthand ambient module and breaks the @types/node 20 url typings; refresh the lockfiles for the new ranges. Closes OpenAPITools#25598
thekhegay
approved these changes
Nov 13, 2026
This branch has not been deployed
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.
Fixes #25598 (regression introduced by #25148, shipped in 7.27.0).
Since 7.27.0 a
typescript-axiosclient generated withnpmNamefails itsnpm install, because thepreparescript now compiles with TypeScript 6 and the generated@types/nodeis never loaded (TypeScript 6 defaultstypesto an empty list):Changes
tsconfig.mustache: list"node"intypesexplicitly.package.mustache: bump@types/nodefrom12.11.5 - 12.20.42to^20.0.0.@types/node12 is incompatible with the TypeScript 6 standard library (DateTimeRangeFormatPart), and@types/node>= 16 needs TypeScript >= 4.9, so the lower bound of thetypescriptrange follows (^4.9).package.mustache: only include^6.0in thetypescriptrange whensupportsES6is set. TypeScript 6 rejectstarget: ES5unlessignoreDeprecationsis"6.0", and TypeScript 5 rejects that value, so one generatedtsconfig.jsoncannot serve both compilers for the ES5 target.custom.d.ts(declare module 'url';) from the petstore builds. It dates from the 2018 scaffold ([TypeScript] add new generator for Axios #892), is not generated, and turnsurlinto a shorthand ambient module, which breaks the@types/node20urltypings (Cannot use namespace '_URL' as a type). Refreshed the three trackedpackage-lock.jsonfiles 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@types/node18 and 20 fail on TypeScript 4.0 and 4.6 (syntax errors in the typings), hence^4.9.npm install(which runsprepare->tsc && tsc -p tsconfig.esm.json) succeeds in all regenerated samples with apackage.json:es6-target(TypeScript 6.0.3 resolved,dist/anddist/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).withNodeImports=true) compiles with TypeScript 6.0.3 after this change../bin/generate-samples.sh ./bin/configs/typescript-axios-*.yamlregenerated the samples; onlypackage.jsonandtsconfig.jsonchanged../mvnw -pl modules/openapi-generator -am -Dtest=TypeScriptAxiosClientCodegenTest -Dsurefire.failIfNoSpecifiedTests=false test: 16 tests, 0 failures.Note: this branch is based on 0a5b61b because current master fails to compile (
CSharpClientCodegen.postProcessAllModelsis defined twice since #25593).PR checklist
typescript-axiosconfigs were regenerated; the change touches no other generator.@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim
Summary by cubic
Fixes generated
typescript-axiosclients failingnpm installwhen thepreparescript resolves TypeScript 6, which no longer loads@types/nodeby default.Bug Fixes
"node"explicitly in the generatedtsconfig.jsontypessoObject.entriesand theurlimport compile under TypeScript 6.@types/nodefrom12.11.5 - 12.20.42to^20.0.0and raises the TypeScript range lower bound to^4.9.ignoreDeprecationsconfiguration fortarget: ES5.declare module 'url'shim from petstore samples, which shadowed the@types/node20urltypings.package.json,tsconfig.json, andpackage-lock.jsonfiles and extends the codegen tests to cover both ranges.Written for commit 185ede7. Summary will update on new commits.