Skip to content

Commit 877a3fc

Browse files
authored
[typescript-fetch] drop support typescript under v4.0 (#12102)
* [typescript-fetch] drop support typescript under v4.0 * [typescript-fetch] update docs * [typescript-fetch] update package-lock.json manually & fix test * [typescript-fetch] fix test
1 parent 478ed9b commit 877a3fc

File tree

98 files changed

+7005
-2375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+7005
-2375
lines changed

bin/configs/typescript-fetch-sagas-and-records.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ additionalProperties:
88
npmRepository: https://skimdb.npmjs.com/registry
99
useSingleRequestParameter: false
1010
supportsES6: true
11-
typescriptThreePlus: true
1211
sagasAndRecords: true
1312
detectPassthroughModelsWithSuffixAndField: 'Response.data'
1413
inferUniqueIdFromNameSuffix: true

bin/configs/typescript-fetch-typescript-three-plus.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs/generators/typescript-fetch.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
3939
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
4040
|stringEnums|Generate string enums instead of objects for enum values.| |false|
4141
|supportsES6|Generate code that conforms to ES6.| |false|
42-
|typescriptThreePlus|Setting this property to true will generate TypeScript 3.6+ compatible code.| |true|
4342
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |true|
4443
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
4544
|withoutRuntimeChecks|Setting this property to true will remove any runtime checks on the request and response payloads. Payloads will be casted to their expected types.| |false|

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
4343
public static final String WITH_INTERFACES = "withInterfaces";
4444
public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter";
4545
public static final String PREFIX_PARAMETER_INTERFACES = "prefixParameterInterfaces";
46-
public static final String TYPESCRIPT_THREE_PLUS = "typescriptThreePlus";
4746
public static final String WITHOUT_RUNTIME_CHECKS = "withoutRuntimeChecks";
4847
public static final String STRING_ENUMS = "stringEnums";
4948
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
@@ -53,7 +52,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
5352
private boolean prefixParameterInterfaces = false;
5453
protected boolean addedApiIndex = false;
5554
protected boolean addedModelIndex = false;
56-
protected boolean typescriptThreePlus = true;
5755
protected boolean withoutRuntimeChecks = false;
5856
protected boolean stringEnums = false;
5957

@@ -97,7 +95,6 @@ public TypeScriptFetchClientCodegen() {
9795
this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
9896
this.cliOptions.add(new CliOption(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, CodegenConstants.USE_SINGLE_REQUEST_PARAMETER_DESC, SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.TRUE.toString()));
9997
this.cliOptions.add(new CliOption(PREFIX_PARAMETER_INTERFACES, "Setting this property to true will generate parameter interface declarations prefixed with API class name to avoid name conflicts.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
100-
this.cliOptions.add(new CliOption(TYPESCRIPT_THREE_PLUS, "Setting this property to true will generate TypeScript 3.6+ compatible code.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.TRUE.toString()));
10198
this.cliOptions.add(new CliOption(WITHOUT_RUNTIME_CHECKS, "Setting this property to true will remove any runtime checks on the request and response payloads. Payloads will be casted to their expected types.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
10299
this.cliOptions.add(new CliOption(SAGAS_AND_RECORDS, "Setting this property to true will generate additional files for use with redux-saga and immutablejs.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
103100
this.cliOptions.add(new CliOption(STRING_ENUMS, STRING_ENUMS_DESC, SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
@@ -121,14 +118,6 @@ public void setNpmRepository(String npmRepository) {
121118
this.npmRepository = npmRepository;
122119
}
123120

124-
public Boolean getTypescriptThreePlus() {
125-
return typescriptThreePlus;
126-
}
127-
128-
public void setTypescriptThreePlus(Boolean typescriptThreePlus) {
129-
this.typescriptThreePlus = typescriptThreePlus;
130-
}
131-
132121
public Boolean getWithoutRuntimeChecks() {
133122
return withoutRuntimeChecks;
134123
}
@@ -233,10 +222,6 @@ public void processOpts() {
233222
addNpmPackageGeneration();
234223
}
235224

236-
if (additionalProperties.containsKey(TYPESCRIPT_THREE_PLUS)) {
237-
this.setTypescriptThreePlus(convertPropertyToBoolean(TYPESCRIPT_THREE_PLUS));
238-
}
239-
240225
if (additionalProperties.containsKey(WITHOUT_RUNTIME_CHECKS)) {
241226
this.setWithoutRuntimeChecks(convertPropertyToBoolean(WITHOUT_RUNTIME_CHECKS));
242227
}

modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ export class {{classname}} extends runtime.BaseAPI {
367367
{{#isEnum}}
368368
{{#stringEnums}}
369369
/**
370-
* @export
371-
* @enum {string}
372-
*/
370+
* @export
371+
* @enum {string}
372+
*/
373373
export enum {{operationIdCamelCase}}{{enumName}} {
374374
{{#allowableValues}}
375375
{{#enumVars}}
@@ -379,7 +379,6 @@ export enum {{operationIdCamelCase}}{{enumName}} {
379379
}
380380
{{/stringEnums}}
381381
{{^stringEnums}}
382-
{{#typescriptThreePlus}}
383382
/**
384383
* @export
385384
*/
@@ -390,18 +389,6 @@ export const {{operationIdCamelCase}}{{enumName}} = {
390389
{{/enumVars}}
391390
{{/allowableValues}}
392391
} as const;
393-
{{/typescriptThreePlus}}
394-
{{^typescriptThreePlus}}
395-
/**
396-
* @export
397-
*/
398-
export const {{operationIdCamelCase}}{{enumName}} = {
399-
{{#allowableValues}}
400-
{{#enumVars}}
401-
{{{name}}}: {{{value}}} as {{{value}}}{{^-last}},{{/-last}}
402-
{{/enumVars}}
403-
{{/allowableValues}}
404-
};{{/typescriptThreePlus}}
405392
export type {{operationIdCamelCase}}{{enumName}} = typeof {{operationIdCamelCase}}{{enumName}}[keyof typeof {{operationIdCamelCase}}{{enumName}}];
406393
{{/stringEnums}}
407394
{{/isEnum}}

modules/openapi-generator/src/main/resources/typescript-fetch/modelEnumInterfaces.mustache

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export enum {{classname}} {
1212
{{/allowableValues}}
1313
}
1414
{{/stringEnums}}{{^stringEnums}}
15-
{{#typescriptThreePlus}}
1615
/**
1716
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
1817
* @export
@@ -24,18 +23,5 @@ export const {{classname}} = {
2423
{{/enumVars}}
2524
{{/allowableValues}}
2625
} as const;
27-
{{/typescriptThreePlus}}
28-
{{^typescriptThreePlus}}
29-
/**
30-
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
31-
* @export
32-
*/
33-
export const {{classname}} = {
34-
{{#allowableValues}}
35-
{{#enumVars}}
36-
{{{name}}}: {{{value}}} as {{{value}}}{{^-last}},{{/-last}}
37-
{{/enumVars}}
38-
{{/allowableValues}}
39-
};{{/typescriptThreePlus}}
4026
export type {{classname}} = typeof {{classname}}[keyof typeof {{classname}}];
4127
{{/stringEnums}}

modules/openapi-generator/src/main/resources/typescript-fetch/modelGenericInterfaces.mustache

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export enum {{classname}}{{enumName}} {
3535
{{/allowableValues}}
3636
}
3737
{{/stringEnums}}{{^stringEnums}}
38-
{{#typescriptThreePlus}}
3938
/**
4039
* @export
4140
*/
@@ -46,18 +45,6 @@ export const {{classname}}{{enumName}} = {
4645
{{/enumVars}}
4746
{{/allowableValues}}
4847
} as const;
49-
{{/typescriptThreePlus}}
50-
{{^typescriptThreePlus}}
51-
/**
52-
* @export
53-
*/
54-
export const {{classname}}{{enumName}} = {
55-
{{#allowableValues}}
56-
{{#enumVars}}
57-
{{{name}}}: {{{value}}} as {{{value}}}{{^-last}},{{/-last}}
58-
{{/enumVars}}
59-
{{/allowableValues}}
60-
};{{/typescriptThreePlus}}
6148
export type {{classname}}{{enumName}} = typeof {{classname}}{{enumName}}[keyof typeof {{classname}}{{enumName}}];
6249
{{/stringEnums}}
6350
{{/isEnum}}{{/vars}}{{/hasEnums}}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"redux-ts-simple": "^3.2.0",
2727
"reselect": "^4.0.0",
2828
{{/sagasAndRecords}}
29-
"typescript": "^{{#typescriptThreePlus}}3.9.5{{/typescriptThreePlus}}{{^typescriptThreePlus}}2.4{{/typescriptThreePlus}}"
29+
"typescript": "^4.0"
3030
}{{#npmRepository}},{{/npmRepository}}
3131
{{#npmRepository}}
3232
"publishConfig": {

modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export const COLLECTION_FORMATS = {
195195
pipes: "|",
196196
};
197197

198-
export type FetchAPI = {{#typescriptThreePlus}}WindowOrWorkerGlobalScope{{/typescriptThreePlus}}{{^typescriptThreePlus}}GlobalFetch{{/typescriptThreePlus}}['fetch'];
198+
export type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
199199

200200
export type Json = any;
201201
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';

modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public class TypeScriptFetchClientOptionsProvider implements OptionsProvider {
3939
private static final String NPM_REPOSITORY = "https://registry.npmjs.org";
4040
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";
4141
public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true";
42-
public static final String TYPESCRIPT_THREE_PLUS = "true";
4342
public static final String WITHOUT_RUNTIME_CHECKS = "true";
4443
public static final String SAGAS_AND_RECORDS = "false";
4544
public static final String ENUM_UNKNOWN_DEFAULT_CASE_VALUE = "false";
@@ -69,7 +68,6 @@ public Map<String, String> createOptions() {
6968
.put(TypeScriptFetchClientCodegen.WITH_INTERFACES, Boolean.FALSE.toString())
7069
.put(TypeScriptFetchClientCodegen.USE_SINGLE_REQUEST_PARAMETER, Boolean.FALSE.toString())
7170
.put(TypeScriptFetchClientCodegen.PREFIX_PARAMETER_INTERFACES, Boolean.FALSE.toString())
72-
.put(TypeScriptFetchClientCodegen.TYPESCRIPT_THREE_PLUS, TYPESCRIPT_THREE_PLUS)
7371
.put(TypeScriptFetchClientCodegen.WITHOUT_RUNTIME_CHECKS, WITHOUT_RUNTIME_CHECKS)
7472
.put(TypeScriptFetchClientCodegen.SAGAS_AND_RECORDS, SAGAS_AND_RECORDS)
7573
.put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE)

0 commit comments

Comments
 (0)