Skip to content

Commit e5e9ca8

Browse files
authored
typescript-axios: support TypeScript 6 (#25148)
* fix: include TypeScript 6 in typescript-axios devDependency range Addresses #24830. * test: cover TypeScript 6 in typescript-axios package template Add a regression assertion for the generated TypeScript dependency range. * fix(typescript-axios): avoid deprecated module resolution Remove the explicit node10 moduleResolution override from generated ES6 tsconfig files. TypeScript 6 deprecates that setting; omitting it preserves the compiler default while keeping generated clients compatible. * test(typescript-axios): cover TS6 tsconfig generation Generate an ES6 client in the TypeScript 6 compatibility regression test and assert its tsconfig does not specify the deprecated node10 resolution option. * Update TypeScript version range in package.json * fix(samples): update TypeScript Axios outputs for TS 6 * fix(samples): update TypeScript Axios outputs for TS 6 Remove 'moduleResolution' option from tsconfig.json * fix(samples): support TypeScript 6 in generated client Update with-complex-headers generated package.json to match the TypeScript Axios template range. * fix(samples): update separate-models TypeScript range Update the with-npm-version-and-separate-models-and-api generated sample. * fix(samples): update with-npm-version for TS 6 Update the with-npm-version generated sample to match the current TypeScript range.
1 parent b7af909 commit e5e9ca8

9 files changed

Lines changed: 31 additions & 10 deletions

File tree

‎modules/openapi-generator/src/main/resources/typescript-axios/package.mustache‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"devDependencies": {
3535
"@types/node": "12.11.5 - 12.20.42",
36-
"typescript": "^4.0 || ^5.0"
36+
"typescript": "^4.0 || ^5.0 || ^6.0"
3737
}{{#npmRepository}},{{/npmRepository}}
3838
{{#npmRepository}}
3939
"publishConfig": {

‎modules/openapi-generator/src/main/resources/typescript-axios/tsconfig.mustache‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
"noImplicitAny": true,
77
"outDir": "dist",
88
"rootDir": ".",
9-
{{#supportsES6}}
10-
"moduleResolution": "node",
11-
{{/supportsES6}}
129
{{^supportsES6}}
1310
"lib": [
1411
"es6",

‎modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/axios/TypeScriptAxiosClientCodegenTest.java‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,4 +280,29 @@ public void generatesTrailingCommasInAsConstEnumObjects() throws Exception {
280280
" Xyz: '(xyz)',\n" +
281281
"} as const;");
282282
}
283+
284+
285+
@Test(description = "Generated package.json supports TypeScript 6")
286+
public void testGeneratedPackageJsonSupportsTypeScript6() throws Exception {
287+
final File output = Files.createTempDirectory("typescript_axios_typescript_6_").toFile();
288+
output.deleteOnExit();
289+
290+
final CodegenConfigurator configurator = new CodegenConfigurator()
291+
.setGeneratorName("typescript-axios")
292+
.setInputSpec("src/test/resources/3_0/petstore.yaml")
293+
.addAdditionalProperty("npmName", "@openapi/typescript-axios-petstore")
294+
.addAdditionalProperty("snapshot", false)
295+
.addAdditionalProperty("npmVersion", "1.0.0-SNAPSHOT")
296+
.addAdditionalProperty("supportsES6", true)
297+
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
298+
299+
final List<File> files = new DefaultGenerator().opts(configurator.toClientOptInput()).generate();
300+
files.forEach(File::deleteOnExit);
301+
302+
TestUtils.assertFileContains(Paths.get(output + "/package.json"),
303+
"\"typescript\": \"^4.0 || ^5.0 || ^6.0\"");
304+
assertThat(Files.readString(Paths.get(output + "/tsconfig.json")))
305+
.doesNotContain("\"moduleResolution\": \"node\"");
306+
307+
}
283308
}

‎samples/client/echo_api/typescript-axios/build/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626
},
2727
"devDependencies": {
2828
"@types/node": "12.11.5 - 12.20.42",
29-
"typescript": "^4.0 || ^5.0"
29+
"typescript": "^4.0 || ^5.0 || ^6.0"
3030
}
3131
}

‎samples/client/petstore/typescript-axios/builds/es6-target/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
"devDependencies": {
3030
"@types/node": "12.11.5 - 12.20.42",
31-
"typescript": "^4.0 || ^5.0"
31+
"typescript": "^4.0 || ^5.0 || ^6.0"
3232
},
3333
"publishConfig": {
3434
"registry": "https://skimdb.npmjs.com/registry"

‎samples/client/petstore/typescript-axios/builds/es6-target/tsconfig.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"noImplicitAny": true,
77
"outDir": "dist",
88
"rootDir": ".",
9-
"moduleResolution": "node",
109
"typeRoots": [
1110
"node_modules/@types"
1211
]

‎samples/client/petstore/typescript-axios/builds/with-complex-headers/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"devDependencies": {
2828
"@types/node": "12.11.5 - 12.20.42",
29-
"typescript": "^4.0 || ^5.0"
29+
"typescript": "^4.0 || ^5.0 || ^6.0"
3030
},
3131
"publishConfig": {
3232
"registry": "https://skimdb.npmjs.com/registry"

‎samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"devDependencies": {
2828
"@types/node": "12.11.5 - 12.20.42",
29-
"typescript": "^4.0 || ^5.0"
29+
"typescript": "^4.0 || ^5.0 || ^6.0"
3030
},
3131
"publishConfig": {
3232
"registry": "https://skimdb.npmjs.com/registry"

‎samples/client/petstore/typescript-axios/builds/with-npm-version/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"devDependencies": {
2828
"@types/node": "12.11.5 - 12.20.42",
29-
"typescript": "^4.0 || ^5.0"
29+
"typescript": "^4.0 || ^5.0 || ^6.0"
3030
},
3131
"publishConfig": {
3232
"registry": "https://skimdb.npmjs.com/registry"

0 commit comments

Comments
 (0)