Skip to content

Commit

Permalink
Remove TypeScript bracket type casting syntax (#3848)
Browse files Browse the repository at this point in the history
  • Loading branch information
VoronFX authored Jan 31, 2022
1 parent 0492e36 commit 631beea
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,23 @@
return this.http.request({% if Framework.Angular.UseHttpClient %}"{{ operation.HttpMethodLower }}", {% endif %}url_, options_).{% if Framework.UseRxJs6 %}pipe({% endif %}{{ Framework.RxJs.ObservableMergeMapMethod }}((response_ : any) => {
{%- endif -%}
{%- if UseTransformResultMethod -%}
return this.transformResult(url_, response_, (r) => this.process{{ operation.ActualOperationNameUpper }}(<any>r));
return this.transformResult(url_, response_, (r) => this.process{{ operation.ActualOperationNameUpper }}(r as any));
{%- else -%}
return this.process{{ operation.ActualOperationNameUpper }}(response_);
{%- endif -%}
}){% if Framework.UseRxJs6 %}){% endif %}.{% if Framework.UseRxJs6 %}pipe({% endif %}{{ Framework.RxJs.ObservableCatchMethod }}((response_: any) => {
if (response_ instanceof {% if Framework.Angular.UseHttpClient %}HttpResponseBase{% else %}Response{% endif %}) {
try {
{%- if UseTransformResultMethod -%}
return this.transformResult(url_, response_, (r) => this.process{{ operation.ActualOperationNameUpper }}(<any>r));
return this.transformResult(url_, response_, (r) => this.process{{ operation.ActualOperationNameUpper }}(r as any));
{%- else -%}
return this.process{{ operation.ActualOperationNameUpper }}(<any>response_);
return this.process{{ operation.ActualOperationNameUpper }}(response_ as any);
{%- endif -%}
} catch (e) {
return <Observable<{{ operation.ResultType }}>><any>{{ Framework.RxJs.ObservableThrowMethod }}(e);
return {{ Framework.RxJs.ObservableThrowMethod }}(e) as any as Observable<{{ operation.ResultType }}>;
}
} else
return <Observable<{{ operation.ResultType }}>><any>{{ Framework.RxJs.ObservableThrowMethod }}(response_);
return {{ Framework.RxJs.ObservableThrowMethod }}(response_) as any as Observable<{{ operation.ResultType }}>;
}){% if Framework.UseRxJs6 %}){% endif %};
}

Expand All @@ -111,7 +111,7 @@
{%- if Framework.Angular.UseHttpClient -%}
const responseBlob =
response instanceof HttpResponse ? response.body :
(<any>response).error instanceof Blob ? (<any>response).error : undefined;
(response as any).error instanceof Blob ? (response as any).error : undefined;
{%- endif -%}

{% template Client.ProcessResponse %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
{% template Client.RequestBody %}
{% endif -%}

var options_ = <ng.IRequestConfig>{
var options_: ng.IRequestConfig = {
url: url_,
method: "{{ operation.HttpMethodUpper | upcase }}",
{% if operation.IsFile -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{% template Client.RequestBody %}

{% endif -%}
let options_ = <AxiosRequestConfig>{
let options_: AxiosRequestConfig = {
{% if operation.HasBody -%}
data: content_,
{% endif -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const fileNameMatch = contentDisposition ? /filename[^;=\n]*=(?:(\\?['"])(.*?)\1
const fileName = fileNameMatch && fileNameMatch.length > 1 ? decodeURIComponent(fileNameMatch[fileNameMatch.length - 1]) : undefined;
{% if operation.WrapResponse -%}
{% if Framework.IsAngular -%}
return {{ Framework.RxJs.ObservableOfMethod }}(new {{ operation.ResponseClass }}(status, _headers, { fileName: fileName, data: {% if Framework.Angular.UseHttpClient %}<any>responseBlob{% else %}<any>response.blob(){% endif %}, status: status, headers: _headers }));
return {{ Framework.RxJs.ObservableOfMethod }}(new {{ operation.ResponseClass }}(status, _headers, { fileName: fileName, data: {% if Framework.Angular.UseHttpClient %}responseBlob as any{% else %}response.blob() as any{% endif %}, status: status, headers: _headers }));
{% elsif Framework.IsAngularJS -%}
return this.q.resolve(new {{ operation.ResponseClass }}(status, _headers, { fileName: fileName, status: status, data: new Blob([response.data]), headers: _headers }));
{% elsif Framework.IsAxios -%}
Expand All @@ -20,7 +20,7 @@ return response.blob().then(blob => { return new {{ operation.ResponseClass }}(s
{% endif -%}
{% else -%}
{% if Framework.IsAngular -%}
return {{ Framework.RxJs.ObservableOfMethod }}({ fileName: fileName, data: {% if Framework.Angular.UseHttpClient %}<any>responseBlob{% else %}<any>response.blob(){% endif %}, status: status, headers: _headers });
return {{ Framework.RxJs.ObservableOfMethod }}({ fileName: fileName, data: {% if Framework.Angular.UseHttpClient %}responseBlob as any{% else %}response.blob() as any{% endif %}, status: status, headers: _headers });
{% elsif Framework.IsAngularJS -%}
return this.q.resolve({ fileName: fileName, status: status, data: new Blob([response.data]), headers: _headers });
{% elsif Framework.IsAxios -%}
Expand All @@ -45,7 +45,7 @@ result{{ response.StatusCode }} = {% unless response.IsPlainText %}JSON.parse({%
let resultData{{ response.StatusCode }} = _responseText === "" ? null : {% if response.IsPlainText %}_responseText{% else %}{% if operation.HandleReferences %}jsonParse{% else %}JSON.parse{% endif %}(_responseText, this.jsonParseReviver){% endif %};
{{ response.DataConversionCode }}
{% else -%}
result{{ response.StatusCode }} = _responseText === "" ? null : <{{ response.Type }}>{% if response.IsPlainText %}_responseText{% else %}{% if operation.HandleReferences %}jsonParse{% else %}JSON.parse{% endif %}(_responseText, this.jsonParseReviver){% endif %};
result{{ response.StatusCode }} = _responseText === "" ? null : {% if response.IsPlainText %}_responseText{% else %}{% if operation.HandleReferences %}jsonParse{% else %}JSON.parse{% endif %}(_responseText, this.jsonParseReviver){% endif %} as {{ response.Type }};
{% endif -%}
{% endif -%}
{% if response.IsSuccess -%}
Expand Down Expand Up @@ -76,25 +76,25 @@ return throwException({% if Framework.IsAngularJS %}this.q, {% endif %}"{{ respo
{% elsif response.IsSuccess -%}
{% if operation.WrapResponse -%}
{% if Framework.IsAngular -%}
return {{ Framework.RxJs.ObservableOfMethod }}<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, <any>null));
return {{ Framework.RxJs.ObservableOfMethod }}<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, null as any));
{% elsif Framework.IsAngularJS -%}
return this.q.resolve<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, <any>null));
return this.q.resolve<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, null as any));
{% elsif Framework.IsAxios -%}
return Promise.resolve<{{ operation.ResultType }}>(new {{ operation.ResultType }}(status, _headers, <any>null));
return Promise.resolve<{{ operation.ResultType }}>(new {{ operation.ResultType }}(status, _headers, null as any));
{% else -%}
return new {{ operation.ResponseClass }}(status, _headers, <any>null);
return new {{ operation.ResponseClass }}(status, _headers, null as any);
{% endif -%}
{% else -%}
{% if Framework.IsAngular -%}
{% if Framework.UseRxJs7 -%}
return {{ Framework.RxJs.ObservableOfMethod }}(<any>null);
return {{ Framework.RxJs.ObservableOfMethod }}(null as any);
{% else -%}
return {{ Framework.RxJs.ObservableOfMethod }}<{{operation.ResultType}}>(<any>null);
return {{ Framework.RxJs.ObservableOfMethod }}<{{operation.ResultType}}>(null as any);
{% endif -%}
{% elsif Framework.IsAngularJS -%}
return this.q.resolve<{{ operation.ResultType }}>(<any>null);
return this.q.resolve<{{ operation.ResultType }}>(null as any);
{% elsif Framework.IsAxios -%}
return Promise.resolve<{{ operation.ResultType }}>(<any>null);
return Promise.resolve<{{ operation.ResultType }}>(null as any);
{% else -%}
return{% if operation.HasResultType %} null{% endif %};
{% endif -%}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
{% if Framework.IsFetchOrAurelia -%}
{% if operation.WrapResponse -%}
return Promise.resolve<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, <any>null));
return Promise.resolve<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, null as any));
{% else -%}
return Promise.resolve<{{ operation.ResultType }}>(<any>null);
return Promise.resolve<{{ operation.ResultType }}>(null as any);
{% endif -%}
{% elsif Framework.IsAxios -%}
{% if operation.WrapResponse -%}
return Promise.resolve<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, <any>null));
return Promise.resolve<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, null as any));
{% else -%}
return Promise.resolve<{{ operation.ResultType }}>(<any>null);
return Promise.resolve<{{ operation.ResultType }}>(null as any);
{% endif -%}
{% elsif Framework.IsAngular -%}
{% if operation.WrapResponse -%}
return {{ Framework.RxJs.ObservableOfMethod }}<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, <any>null));
return {{ Framework.RxJs.ObservableOfMethod }}<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, null as any));
{% else -%}
{% if Framework.UseRxJs7 -%}
return {{ Framework.RxJs.ObservableOfMethod }}(<any>null);
return {{ Framework.RxJs.ObservableOfMethod }}(null as any);
{% else -%}
return {{ Framework.RxJs.ObservableOfMethod }}<{{ operation.ResultType }}>(<any>null);
return {{ Framework.RxJs.ObservableOfMethod }}<{{ operation.ResultType }}>(null as any);
{% endif -%}
{% endif -%}
{% elsif Framework.IsAngularJS -%}
{% if operation.WrapResponse -%}
return this.q.resolve<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, <any>null));
return this.q.resolve<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, null as any));
{% else -%}
return this.q.resolve<{{ operation.ResultType }}>(<any>null);
return this.q.resolve<{{ operation.ResultType }}>(null as any);
{% endif -%}
{% else -%}
{% if operation.WrapResponse -%}
return new {{ operation.ResponseClass }}(status, _headers, <any>null);
return new {{ operation.ResponseClass }}(status, _headers, null as any);
{% else -%}
return{% if operation.HasResultType %} null{% endif %};
{% endif -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ else if ({{ parameter.VariableName }} !== undefined)
{{ parameter.VariableName }} && {{ parameter.VariableName }}.forEach((item_, index_) => {
for (let attr_ in item_) {
if (item_.hasOwnProperty(attr_)) {
content_ += encodeURIComponent("{{ parameter.Name }}[" + index_ + "]." + attr_) + "=" + encodeURIComponent("" + (<any>item_)[attr_]) + "&";
content_ += encodeURIComponent("{{ parameter.Name }}[" + index_ + "]." + attr_) + "=" + encodeURIComponent("" + (item_ as any)[attr_]) + "&";
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ else if ({{ parameter.VariableName }} !== undefined)
{{ parameter.VariableName }} && {{ parameter.VariableName }}.forEach((item, index) => {
for (let attr in item)
if (item.hasOwnProperty(attr)) {
url_ += "{{ parameter.Name }}[" + index + "]." + attr + "=" + encodeURIComponent("" + (<any>item)[attr]) + "&";
url_ += "{{ parameter.Name }}[" + index + "]." + attr + "=" + encodeURIComponent("" + (item as any)[attr]) + "&";
}
});
{% elsif parameter.IsDateOrDateTime -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{%- if HasBaseClass -%}
super({% if HasConfigurationClass %}configuration{% endif %});
{%- endif -%}
this.http = http ? http : <any>window;
this.http = http ? http : window as any;
{%- if UseGetBaseUrlMethod -%}
this.baseUrl = this.getBaseUrl("{{ BaseUrl }}", baseUrl);
{%- else -%}
Expand All @@ -43,7 +43,7 @@
{% template Client.RequestBody %}

{%- endif -%}
let options_ = <RequestInit>{
let options_: RequestInit = {
{%- if operation.HasBody -%}
body: content_,
{%- endif -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function blobToText(blob: any): Observable<string> {
} else {
let reader = new FileReader();
reader.onload = event => {
observer.next((<any>event.target).result);
observer.next((event.target as any).result);
observer.complete();
};
reader.readAsText(blob);
Expand All @@ -57,7 +57,7 @@ function blobToText(blob: any): Observable<string> {
function blobToText(blob: Blob, q: ng.IQService): ng.IPromise<string> {
return new q((resolve) => {
let reader = new FileReader();
reader.onload = event => resolve((<any>event.target).result);
reader.onload = event => resolve((event.target as any).result);
reader.readAsText(blob);
});
}
Expand Down

0 comments on commit 631beea

Please sign in to comment.