[typescript] make TypeScript version configurable (#20064)

This commit is contained in:
Dennis Ameling
2026-02-04 12:01:22 +01:00
committed by GitHub
parent 48b7c85cd4
commit 9547ebdc98
17 changed files with 25 additions and 15 deletions

View File

@@ -42,6 +42,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|supportsES6|Generate code that conforms to ES6.| |false|
|typescriptMajorVersion|Specify the major version of TypeScript to use in the client code. Default is 5.| |5|
|useErasableSyntax|Use erasable syntax for the generated code. This is a temporary feature and will be removed in the future.| |false|
|useInversify|Enable this to generate decorators and service identifiers for the InversifyJS inversion of control container. If you set 'deno' as 'platform', the generator will process this value as 'disable'.| |false|
|useObjectParameters|Use aggregate parameter objects as function arguments for api operations instead of passing each parameter as a separate function argument.| |false|

View File

@@ -78,6 +78,9 @@ public class TypeScriptClientCodegen extends AbstractTypeScriptClientCodegen imp
private static final String USE_OBJECT_PARAMS_SWITCH = "useObjectParameters";
private static final String USE_OBJECT_PARAMS_DESC = "Use aggregate parameter objects as function arguments for api operations instead of passing each parameter as a separate function argument.";
protected static final String TYPESCRIPT_MAJOR_VERSION_SWTICH = "typescriptMajorVersion";
private static final String TYPESCRIPT_MAJOR_VERSION_DESC = "Specify the major version of TypeScript to use in the client code. Default is 5.";
public static final String USE_ERASABLE_SYNTAX = "useErasableSyntax";
public static final String USE_ERASABLE_SYNTAX_DESC = "Use erasable syntax for the generated code. This is a temporary feature and will be removed in the future.";
@@ -97,6 +100,9 @@ public class TypeScriptClientCodegen extends AbstractTypeScriptClientCodegen imp
protected String snapshot = null;
protected ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = ENUM_PROPERTY_NAMING_TYPE.PascalCase;
@Getter @Setter
protected String typescriptMajorVersion = "5";
private final DateTimeFormatter iso8601Date = DateTimeFormatter.ISO_DATE;
private final DateTimeFormatter iso8601DateTime = DateTimeFormatter.ISO_DATE_TIME;
@@ -131,6 +137,7 @@ public class TypeScriptClientCodegen extends AbstractTypeScriptClientCodegen imp
cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_RXJS_SWITCH, TypeScriptClientCodegen.USE_RXJS_SWITCH_DESC).defaultValue("false"));
cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_OBJECT_PARAMS_SWITCH, TypeScriptClientCodegen.USE_OBJECT_PARAMS_DESC).defaultValue("false"));
cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_INVERSIFY_SWITCH, TypeScriptClientCodegen.USE_INVERSIFY_SWITCH_DESC).defaultValue("false"));
cliOptions.add(new CliOption(TypeScriptClientCodegen.TYPESCRIPT_MAJOR_VERSION_SWTICH, TypeScriptClientCodegen.TYPESCRIPT_MAJOR_VERSION_DESC).defaultValue(this.getTypescriptMajorVersion()));
cliOptions.add(new CliOption(TypeScriptClientCodegen.IMPORT_FILE_EXTENSION_SWITCH, TypeScriptClientCodegen.IMPORT_FILE_EXTENSION_SWITCH_DESC));
cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_ERASABLE_SYNTAX, TypeScriptClientCodegen.USE_ERASABLE_SYNTAX_DESC).defaultValue("false"));
@@ -495,6 +502,8 @@ public class TypeScriptClientCodegen extends AbstractTypeScriptClientCodegen imp
if (additionalProperties.containsKey(NPM_REPOSITORY)) {
setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString());
}
additionalProperties.put(TYPESCRIPT_MAJOR_VERSION_SWTICH, typescriptMajorVersion);
}
private String getHttpLibForFramework(String object) {

View File

@@ -71,7 +71,7 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^{{typescriptMajorVersion}}.0"
}{{#npmRepository}},{{/npmRepository}}
{{#npmRepository}}
"publishConfig":{

View File

@@ -38,6 +38,6 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
}
}

View File

@@ -36,6 +36,6 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
}
}

View File

@@ -36,6 +36,6 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
}
}

View File

@@ -36,6 +36,6 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
}
}

View File

@@ -36,6 +36,6 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
}
}

View File

@@ -38,6 +38,6 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
}
}

View File

@@ -36,6 +36,6 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
}
}

View File

@@ -36,6 +36,6 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
}
}

View File

@@ -38,6 +38,6 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
}
}

View File

@@ -38,6 +38,6 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
}
}

View File

@@ -39,6 +39,6 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
}
}

View File

@@ -37,6 +37,6 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
}
}

View File

@@ -36,6 +36,6 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
}
}

View File

@@ -38,6 +38,6 @@
"es6-promise": "^4.2.4"
},
"devDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
}
}