Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
{{/withAWSV4Signature}}
},
"devDependencies": {
"@types/node": "12.11.5 - 12.20.42",
"typescript": "^4.0 || ^5.0 || ^6.0"
"@types/node": "^20.0.0",
"typescript": "^4.9 || ^5.0{{#supportsES6}} || ^6.0{{/supportsES6}}"
}{{#npmRepository}},{{/npmRepository}}
{{#npmRepository}}
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
{{/supportsES6}}
"typeRoots": [
"node_modules/@types"
],
"types": [
"node"
]
},
"exclude": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,35 @@ public void testGeneratedPackageJsonSupportsTypeScript6() throws Exception {
files.forEach(File::deleteOnExit);

TestUtils.assertFileContains(Paths.get(output + "/package.json"),
"\"typescript\": \"^4.0 || ^5.0 || ^6.0\"");
assertThat(Files.readString(Paths.get(output + "/tsconfig.json")))
.doesNotContain("\"moduleResolution\": \"node\"");
"\"typescript\": \"^4.9 || ^5.0 || ^6.0\"",
"\"@types/node\": \"^20.0.0\"");
final String tsconfig = Files.readString(Paths.get(output + "/tsconfig.json"));
assertThat(tsconfig).doesNotContain("\"moduleResolution\": \"node\"");
// TypeScript 6 no longer loads every package under node_modules/@types by default,
// so @types/node must be listed explicitly for Object.entries and the "url" import.
assertThat(tsconfig).contains("\"types\": [\n \"node\"\n ]");
}

@Test(description = "Generated package.json keeps TypeScript 5 for the ES5 target")
public void testGeneratedPackageJsonKeepsTypeScript5ForEs5Target() throws Exception {
final File output = Files.createTempDirectory("typescript_axios_es5_typescript_").toFile();
output.deleteOnExit();

final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("typescript-axios")
.setInputSpec("src/test/resources/3_0/petstore.yaml")
.addAdditionalProperty("npmName", "@openapi/typescript-axios-petstore")
.addAdditionalProperty("snapshot", false)
.addAdditionalProperty("npmVersion", "1.0.0-SNAPSHOT")
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));

final List<File> files = new DefaultGenerator().opts(configurator.toClientOptInput()).generate();
files.forEach(File::deleteOnExit);

// TypeScript 6 rejects target ES5 unless ignoreDeprecations is "6.0", a value TypeScript 5 rejects.
TestUtils.assertFileContains(Paths.get(output + "/package.json"),
"\"typescript\": \"^4.9 || ^5.0\"",
"\"@types/node\": \"^20.0.0\"");
TestUtils.assertFileNotContains(Paths.get(output + "/package.json"), "^6.0");
}
}
124 changes: 93 additions & 31 deletions samples/client/echo_api/typescript-axios/build/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions samples/client/echo_api/typescript-axios/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"axios": "^1.18.0"
},
"devDependencies": {
"@types/node": "12.11.5 - 12.20.42",
"typescript": "^4.0 || ^5.0 || ^6.0"
"@types/node": "^20.0.0",
"typescript": "^4.9 || ^5.0"
}
}
3 changes: 3 additions & 0 deletions samples/client/echo_api/typescript-axios/build/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
],
"typeRoots": [
"node_modules/@types"
],
"types": [
"node"
]
},
"exclude": [
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"axios": "^1.18.0"
},
"devDependencies": {
"@types/node": "12.11.5 - 12.20.42",
"typescript": "^4.0 || ^5.0 || ^6.0"
"@types/node": "^20.0.0",
"typescript": "^4.9 || ^5.0 || ^6.0"
},
"publishConfig": {
"registry": "https://skimdb.npmjs.com/registry"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"rootDir": ".",
"typeRoots": [
"node_modules/@types"
],
"types": [
"node"
]
},
"exclude": [
Expand Down

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"axios": "^1.18.0"
},
"devDependencies": {
"@types/node": "12.11.5 - 12.20.42",
"typescript": "^4.0 || ^5.0 || ^6.0"
"@types/node": "^20.0.0",
"typescript": "^4.9 || ^5.0"
},
"publishConfig": {
"registry": "https://skimdb.npmjs.com/registry"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
],
"typeRoots": [
"node_modules/@types"
],
"types": [
"node"
]
},
"exclude": [
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading