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-nestjs] Compatability with tsc 'strict' flag #17672

Merged
merged 2 commits into from
Mar 9, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ export class ApiModule {
}

private static createAsyncProviders(options: AsyncConfiguration): Provider[] {
if (options.useExisting || options.useFactory) {
return [this.createAsyncConfigurationProvider(options)];
if (options.useClass) {
return [
this.createAsyncConfigurationProvider(options),
{
provide: options.useClass,
useClass: options.useClass,
},
];
}
return [
this.createAsyncConfigurationProvider(options),
{
provide: options.useClass,
useClass: options.useClass,
},
];
return [this.createAsyncConfigurationProvider(options)];
}

private static createAsyncConfigurationProvider(
Expand All @@ -73,7 +73,7 @@ export class ApiModule {
provide: Configuration,
useFactory: async (optionsFactory: ConfigurationFactory) =>
await optionsFactory.createConfiguration(),
inject: [options.useExisting || options.useClass],
inject: (options.useExisting && [options.useExisting]) || (options.useClass && [options.useClass]) || [],
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class {{classname}} {
// authentication ({{name}}) required
{{#isApiKey}}
{{#isKeyInHeader}}
if (this.configuration.apiKeys["{{keyParamName}}"]) {
if (this.configuration.apiKeys?.["{{keyParamName}}"]) {
headers['{{keyParamName}}'] = this.configuration.apiKeys["{{keyParamName}}"];
}

Expand All @@ -130,7 +130,7 @@ export class {{classname}} {
{{^hasQueryParams}}
let queryParameters = new URLSearchParams();
{{/hasQueryParams}}
if (this.configuration.apiKeys["{{keyParamName}}"]) {
if (this.configuration.apiKeys?.["{{keyParamName}}"]) {
queryParameters.append('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
}

Expand Down Expand Up @@ -201,24 +201,24 @@ export class {{classname}} {
if ({{paramName}}) {
{{#isCollectionFormatMulti}}
{{paramName}}.forEach((element) => {
formParams.append('{{baseName}}', <any>element);
formParams!.append('{{baseName}}', <any>element);
macjohnny marked this conversation as resolved.
Show resolved Hide resolved
})
{{/isCollectionFormatMulti}}
{{^isCollectionFormatMulti}}
formParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']));
formParams!.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']));
{{/isCollectionFormatMulti}}
}
{{/isArray}}
{{^isArray}}
if ({{paramName}} !== undefined) {
formParams.append('{{baseName}}', <any>{{paramName}});
formParams!.append('{{baseName}}', <any>{{paramName}});
}
{{/isArray}}
{{/formParams}}

{{/hasFormParams}}
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.basePath}{{{path}}}`,{{#isBodyAllowed}}
{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}convertFormParamsToString ? formParams.toString() : formParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isBodyAllowed}}
{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}convertFormParamsToString ? formParams!.toString() : formParams!{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isBodyAllowed}}
{
{{#hasQueryParams}}
params: queryParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ export class ApiModule {
}

private static createAsyncProviders(options: AsyncConfiguration): Provider[] {
if (options.useExisting || options.useFactory) {
return [this.createAsyncConfigurationProvider(options)];
if (options.useClass) {
return [
this.createAsyncConfigurationProvider(options),
{
provide: options.useClass,
useClass: options.useClass,
},
];
}
return [
this.createAsyncConfigurationProvider(options),
{
provide: options.useClass,
useClass: options.useClass,
},
];
return [this.createAsyncConfigurationProvider(options)];
}

private static createAsyncConfigurationProvider(
Expand All @@ -67,7 +67,7 @@ export class ApiModule {
provide: Configuration,
useFactory: async (optionsFactory: ConfigurationFactory) =>
await optionsFactory.createConfiguration(),
inject: [options.useExisting || options.useClass],
inject: (options.useExisting && [options.useExisting]) || (options.useClass && [options.useClass]) || [],
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export class PetService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down Expand Up @@ -383,15 +383,15 @@ export class PetService {
}

if (name !== undefined) {
formParams.append('name', <any>name);
formParams!.append('name', <any>name);
}

if (status !== undefined) {
formParams.append('status', <any>status);
formParams!.append('status', <any>status);
}

return this.httpClient.post<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
convertFormParamsToString ? formParams.toString() : formParams,
convertFormParamsToString ? formParams!.toString() : formParams!,
{
withCredentials: this.configuration.withCredentials,
headers: headers
Expand Down Expand Up @@ -456,15 +456,15 @@ export class PetService {
}

if (additionalMetadata !== undefined) {
formParams.append('additionalMetadata', <any>additionalMetadata);
formParams!.append('additionalMetadata', <any>additionalMetadata);
}

if (file !== undefined) {
formParams.append('file', <any>file);
formParams!.append('file', <any>file);
}

return this.httpClient.post<ApiResponse>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
convertFormParamsToString ? formParams.toString() : formParams,
convertFormParamsToString ? formParams!.toString() : formParams!,
{
withCredentials: this.configuration.withCredentials,
headers: headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class StoreService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class UserService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down Expand Up @@ -101,7 +101,7 @@ export class UserService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down Expand Up @@ -146,7 +146,7 @@ export class UserService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down Expand Up @@ -191,7 +191,7 @@ export class UserService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down Expand Up @@ -311,7 +311,7 @@ export class UserService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down Expand Up @@ -355,7 +355,7 @@ export class UserService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ export class ApiModule {
}

private static createAsyncProviders(options: AsyncConfiguration): Provider[] {
if (options.useExisting || options.useFactory) {
return [this.createAsyncConfigurationProvider(options)];
if (options.useClass) {
return [
this.createAsyncConfigurationProvider(options),
{
provide: options.useClass,
useClass: options.useClass,
},
];
}
return [
this.createAsyncConfigurationProvider(options),
{
provide: options.useClass,
useClass: options.useClass,
},
];
return [this.createAsyncConfigurationProvider(options)];
}

private static createAsyncConfigurationProvider(
Expand All @@ -68,7 +68,7 @@ export class ApiModule {
provide: Configuration,
useFactory: async (optionsFactory: ConfigurationFactory) =>
await optionsFactory.createConfiguration(),
inject: [options.useExisting || options.useClass],
inject: (options.useExisting && [options.useExisting]) || (options.useClass && [options.useClass]) || [],
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class PetService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down Expand Up @@ -384,15 +384,15 @@ export class PetService {
}

if (name !== undefined) {
formParams.append('name', <any>name);
formParams!.append('name', <any>name);
}

if (status !== undefined) {
formParams.append('status', <any>status);
formParams!.append('status', <any>status);
}

return this.httpClient.post<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
convertFormParamsToString ? formParams.toString() : formParams,
convertFormParamsToString ? formParams!.toString() : formParams!,
{
withCredentials: this.configuration.withCredentials,
headers: headers
Expand Down Expand Up @@ -457,15 +457,15 @@ export class PetService {
}

if (additionalMetadata !== undefined) {
formParams.append('additionalMetadata', <any>additionalMetadata);
formParams!.append('additionalMetadata', <any>additionalMetadata);
}

if (file !== undefined) {
formParams.append('file', <any>file);
formParams!.append('file', <any>file);
}

return this.httpClient.post<ApiResponse>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
convertFormParamsToString ? formParams.toString() : formParams,
convertFormParamsToString ? formParams!.toString() : formParams!,
{
withCredentials: this.configuration.withCredentials,
headers: headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class StoreService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class UserService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down Expand Up @@ -102,7 +102,7 @@ export class UserService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down Expand Up @@ -147,7 +147,7 @@ export class UserService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down Expand Up @@ -192,7 +192,7 @@ export class UserService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down Expand Up @@ -312,7 +312,7 @@ export class UserService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down Expand Up @@ -356,7 +356,7 @@ export class UserService {
let headers = {...this.defaultHeaders};

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
if (this.configuration.apiKeys?.["api_key"]) {
headers['api_key'] = this.configuration.apiKeys["api_key"];
}

Expand Down