Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[typescript-fetch] drop support typescript under v4.0 #12102

Merged
Merged
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
1 change: 0 additions & 1 deletion bin/configs/typescript-fetch-sagas-and-records.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ additionalProperties:
npmRepository: https://skimdb.npmjs.com/registry
useSingleRequestParameter: false
supportsES6: true
typescriptThreePlus: true
sagasAndRecords: true
detectPassthroughModelsWithSuffixAndField: 'Response.data'
inferUniqueIdFromNameSuffix: true
Expand Down
10 changes: 0 additions & 10 deletions bin/configs/typescript-fetch-typescript-three-plus.yaml

This file was deleted.

1 change: 0 additions & 1 deletion docs/generators/typescript-fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|stringEnums|Generate string enums instead of objects for enum values.| |false|
|supportsES6|Generate code that conforms to ES6.| |false|
|typescriptThreePlus|Setting this property to true will generate TypeScript 3.6+ compatible code.| |true|
|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|
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|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|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
public static final String WITH_INTERFACES = "withInterfaces";
public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter";
public static final String PREFIX_PARAMETER_INTERFACES = "prefixParameterInterfaces";
public static final String TYPESCRIPT_THREE_PLUS = "typescriptThreePlus";
public static final String WITHOUT_RUNTIME_CHECKS = "withoutRuntimeChecks";
public static final String STRING_ENUMS = "stringEnums";
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
Expand All @@ -53,7 +52,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
private boolean prefixParameterInterfaces = false;
protected boolean addedApiIndex = false;
protected boolean addedModelIndex = false;
protected boolean typescriptThreePlus = true;
protected boolean withoutRuntimeChecks = false;
protected boolean stringEnums = false;

Expand Down Expand Up @@ -97,7 +95,6 @@ public TypeScriptFetchClientCodegen() {
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()));
this.cliOptions.add(new CliOption(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, CodegenConstants.USE_SINGLE_REQUEST_PARAMETER_DESC, SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.TRUE.toString()));
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()));
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()));
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()));
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()));
this.cliOptions.add(new CliOption(STRING_ENUMS, STRING_ENUMS_DESC, SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
Expand All @@ -121,14 +118,6 @@ public void setNpmRepository(String npmRepository) {
this.npmRepository = npmRepository;
}

public Boolean getTypescriptThreePlus() {
return typescriptThreePlus;
}

public void setTypescriptThreePlus(Boolean typescriptThreePlus) {
this.typescriptThreePlus = typescriptThreePlus;
}

public Boolean getWithoutRuntimeChecks() {
return withoutRuntimeChecks;
}
Expand Down Expand Up @@ -233,10 +222,6 @@ public void processOpts() {
addNpmPackageGeneration();
}

if (additionalProperties.containsKey(TYPESCRIPT_THREE_PLUS)) {
this.setTypescriptThreePlus(convertPropertyToBoolean(TYPESCRIPT_THREE_PLUS));
}

if (additionalProperties.containsKey(WITHOUT_RUNTIME_CHECKS)) {
this.setWithoutRuntimeChecks(convertPropertyToBoolean(WITHOUT_RUNTIME_CHECKS));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ export class {{classname}} extends runtime.BaseAPI {
{{#isEnum}}
{{#stringEnums}}
/**
* @export
* @enum {string}
*/
* @export
* @enum {string}
*/
export enum {{operationIdCamelCase}}{{enumName}} {
{{#allowableValues}}
{{#enumVars}}
Expand All @@ -379,7 +379,6 @@ export enum {{operationIdCamelCase}}{{enumName}} {
}
{{/stringEnums}}
{{^stringEnums}}
{{#typescriptThreePlus}}
/**
* @export
*/
Expand All @@ -390,18 +389,6 @@ export const {{operationIdCamelCase}}{{enumName}} = {
{{/enumVars}}
{{/allowableValues}}
} as const;
{{/typescriptThreePlus}}
{{^typescriptThreePlus}}
/**
* @export
*/
export const {{operationIdCamelCase}}{{enumName}} = {
{{#allowableValues}}
{{#enumVars}}
{{{name}}}: {{{value}}} as {{{value}}}{{^-last}},{{/-last}}
{{/enumVars}}
{{/allowableValues}}
};{{/typescriptThreePlus}}
export type {{operationIdCamelCase}}{{enumName}} = typeof {{operationIdCamelCase}}{{enumName}}[keyof typeof {{operationIdCamelCase}}{{enumName}}];
{{/stringEnums}}
{{/isEnum}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export enum {{classname}} {
{{/allowableValues}}
}
{{/stringEnums}}{{^stringEnums}}
{{#typescriptThreePlus}}
/**
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
* @export
Expand All @@ -24,18 +23,5 @@ export const {{classname}} = {
{{/enumVars}}
{{/allowableValues}}
} as const;
{{/typescriptThreePlus}}
{{^typescriptThreePlus}}
/**
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
* @export
*/
export const {{classname}} = {
{{#allowableValues}}
{{#enumVars}}
{{{name}}}: {{{value}}} as {{{value}}}{{^-last}},{{/-last}}
{{/enumVars}}
{{/allowableValues}}
};{{/typescriptThreePlus}}
export type {{classname}} = typeof {{classname}}[keyof typeof {{classname}}];
{{/stringEnums}}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export enum {{classname}}{{enumName}} {
{{/allowableValues}}
}
{{/stringEnums}}{{^stringEnums}}
{{#typescriptThreePlus}}
/**
* @export
*/
Expand All @@ -46,18 +45,6 @@ export const {{classname}}{{enumName}} = {
{{/enumVars}}
{{/allowableValues}}
} as const;
{{/typescriptThreePlus}}
{{^typescriptThreePlus}}
/**
* @export
*/
export const {{classname}}{{enumName}} = {
{{#allowableValues}}
{{#enumVars}}
{{{name}}}: {{{value}}} as {{{value}}}{{^-last}},{{/-last}}
{{/enumVars}}
{{/allowableValues}}
};{{/typescriptThreePlus}}
export type {{classname}}{{enumName}} = typeof {{classname}}{{enumName}}[keyof typeof {{classname}}{{enumName}}];
{{/stringEnums}}
{{/isEnum}}{{/vars}}{{/hasEnums}}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"redux-ts-simple": "^3.2.0",
"reselect": "^4.0.0",
{{/sagasAndRecords}}
"typescript": "^{{#typescriptThreePlus}}3.9.5{{/typescriptThreePlus}}{{^typescriptThreePlus}}2.4{{/typescriptThreePlus}}"
"typescript": "^4.0"
}{{#npmRepository}},{{/npmRepository}}
{{#npmRepository}}
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export const COLLECTION_FORMATS = {
pipes: "|",
};

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

export type Json = any;
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public class TypeScriptFetchClientOptionsProvider implements OptionsProvider {
private static final String NPM_REPOSITORY = "https://registry.npmjs.org";
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";
public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true";
public static final String TYPESCRIPT_THREE_PLUS = "true";
public static final String WITHOUT_RUNTIME_CHECKS = "true";
public static final String SAGAS_AND_RECORDS = "false";
public static final String ENUM_UNKNOWN_DEFAULT_CASE_VALUE = "false";
Expand Down Expand Up @@ -69,7 +68,6 @@ public Map<String, String> createOptions() {
.put(TypeScriptFetchClientCodegen.WITH_INTERFACES, Boolean.FALSE.toString())
.put(TypeScriptFetchClientCodegen.USE_SINGLE_REQUEST_PARAMETER, Boolean.FALSE.toString())
.put(TypeScriptFetchClientCodegen.PREFIX_PARAMETER_INTERFACES, Boolean.FALSE.toString())
.put(TypeScriptFetchClientCodegen.TYPESCRIPT_THREE_PLUS, TYPESCRIPT_THREE_PLUS)
.put(TypeScriptFetchClientCodegen.WITHOUT_RUNTIME_CHECKS, WITHOUT_RUNTIME_CHECKS)
.put(TypeScriptFetchClientCodegen.SAGAS_AND_RECORDS, SAGAS_AND_RECORDS)
.put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ protected void verifyOptions() {
verify(clientCodegen).setParamNaming(TypeScriptFetchClientOptionsProvider.PARAM_NAMING_VALUE);
verify(clientCodegen).setSupportsES6(TypeScriptFetchClientOptionsProvider.SUPPORTS_ES6_VALUE);
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(TypeScriptFetchClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
verify(clientCodegen).setTypescriptThreePlus(Boolean.valueOf(TypeScriptFetchClientOptionsProvider.TYPESCRIPT_THREE_PLUS));
verify(clientCodegen).setWithoutRuntimeChecks(Boolean.valueOf(TypeScriptFetchClientOptionsProvider.WITHOUT_RUNTIME_CHECKS));
verify(clientCodegen).setSagasAndRecords(Boolean.valueOf(TypeScriptFetchClientOptionsProvider.SAGAS_AND_RECORDS));
verify(clientCodegen).setEnumUnknownDefaultCase(Boolean.parseBoolean(TypeScriptFetchClientOptionsProvider.ENUM_UNKNOWN_DEFAULT_CASE_VALUE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -930,69 +930,69 @@ export class FakeApi extends runtime.BaseAPI {
}

/**
* @export
*/
* @export
*/
export const TestEnumParametersEnumHeaderStringArrayEnum = {
GreaterThan: '>' as '>',
Dollar: '$' as '$'
};
GreaterThan: '>',
Dollar: '$'
} as const;
export type TestEnumParametersEnumHeaderStringArrayEnum = typeof TestEnumParametersEnumHeaderStringArrayEnum[keyof typeof TestEnumParametersEnumHeaderStringArrayEnum];
/**
* @export
*/
* @export
*/
export const TestEnumParametersEnumHeaderStringEnum = {
Abc: '_abc' as '_abc',
Efg: '-efg' as '-efg',
Xyz: '(xyz)' as '(xyz)'
};
Abc: '_abc',
Efg: '-efg',
Xyz: '(xyz)'
} as const;
export type TestEnumParametersEnumHeaderStringEnum = typeof TestEnumParametersEnumHeaderStringEnum[keyof typeof TestEnumParametersEnumHeaderStringEnum];
/**
* @export
*/
* @export
*/
export const TestEnumParametersEnumQueryStringArrayEnum = {
GreaterThan: '>' as '>',
Dollar: '$' as '$'
};
GreaterThan: '>',
Dollar: '$'
} as const;
export type TestEnumParametersEnumQueryStringArrayEnum = typeof TestEnumParametersEnumQueryStringArrayEnum[keyof typeof TestEnumParametersEnumQueryStringArrayEnum];
/**
* @export
*/
* @export
*/
export const TestEnumParametersEnumQueryStringEnum = {
Abc: '_abc' as '_abc',
Efg: '-efg' as '-efg',
Xyz: '(xyz)' as '(xyz)'
};
Abc: '_abc',
Efg: '-efg',
Xyz: '(xyz)'
} as const;
export type TestEnumParametersEnumQueryStringEnum = typeof TestEnumParametersEnumQueryStringEnum[keyof typeof TestEnumParametersEnumQueryStringEnum];
/**
* @export
*/
* @export
*/
export const TestEnumParametersEnumQueryIntegerEnum = {
NUMBER_1: 1 as 1,
NUMBER_MINUS_2: -2 as -2
};
NUMBER_1: 1,
NUMBER_MINUS_2: -2
} as const;
export type TestEnumParametersEnumQueryIntegerEnum = typeof TestEnumParametersEnumQueryIntegerEnum[keyof typeof TestEnumParametersEnumQueryIntegerEnum];
/**
* @export
*/
* @export
*/
export const TestEnumParametersEnumQueryDoubleEnum = {
NUMBER_1_DOT_1: 1.1 as 1.1,
NUMBER_MINUS_1_DOT_2: -1.2 as -1.2
};
NUMBER_1_DOT_1: 1.1,
NUMBER_MINUS_1_DOT_2: -1.2
} as const;
export type TestEnumParametersEnumQueryDoubleEnum = typeof TestEnumParametersEnumQueryDoubleEnum[keyof typeof TestEnumParametersEnumQueryDoubleEnum];
/**
* @export
*/
* @export
*/
export const TestEnumParametersEnumFormStringArrayEnum = {
GreaterThan: '>' as '>',
Dollar: '$' as '$'
};
GreaterThan: '>',
Dollar: '$'
} as const;
export type TestEnumParametersEnumFormStringArrayEnum = typeof TestEnumParametersEnumFormStringArrayEnum[keyof typeof TestEnumParametersEnumFormStringArrayEnum];
/**
* @export
*/
* @export
*/
export const TestEnumParametersEnumFormStringEnum = {
Abc: '_abc' as '_abc',
Efg: '-efg' as '-efg',
Xyz: '(xyz)' as '(xyz)'
};
Abc: '_abc',
Efg: '-efg',
Xyz: '(xyz)'
} as const;
export type TestEnumParametersEnumFormStringEnum = typeof TestEnumParametersEnumFormStringEnum[keyof typeof TestEnumParametersEnumFormStringEnum];
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,11 @@ export class PetApi extends runtime.BaseAPI {
}

/**
* @export
*/
* @export
*/
export const FindPetsByStatusStatusEnum = {
Available: 'available' as 'available',
Pending: 'pending' as 'pending',
Sold: 'sold' as 'sold'
};
Available: 'available',
Pending: 'pending',
Sold: 'sold'
} as const;
export type FindPetsByStatusStatusEnum = typeof FindPetsByStatusStatusEnum[keyof typeof FindPetsByStatusStatusEnum];
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ export interface EnumArrays {
* @export
*/
export const EnumArraysJustSymbolEnum = {
GreaterThanOrEqualTo: '>=' as '>=',
Dollar: '$' as '$'
};
GreaterThanOrEqualTo: '>=',
Dollar: '$'
} as const;
export type EnumArraysJustSymbolEnum = typeof EnumArraysJustSymbolEnum[keyof typeof EnumArraysJustSymbolEnum];

/**
* @export
*/
export const EnumArraysArrayEnumEnum = {
Fish: 'fish' as 'fish',
Crab: 'crab' as 'crab'
};
Fish: 'fish',
Crab: 'crab'
} as const;
export type EnumArraysArrayEnumEnum = typeof EnumArraysArrayEnumEnum[keyof typeof EnumArraysArrayEnumEnum];


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
* @export
*/
export const EnumClass = {
Abc: '_abc' as '_abc',
Efg: '-efg' as '-efg',
Xyz: '(xyz)' as '(xyz)'
};
Abc: '_abc',
Efg: '-efg',
Xyz: '(xyz)'
} as const;
export type EnumClass = typeof EnumClass[keyof typeof EnumClass];


Expand Down
Loading