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-node] Fix invalid type when using node@10 and ES5 #7133

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 @@ -12,7 +12,7 @@ import * as fs from 'fs';
import * as http from 'http';

export class HttpError extends Error {
constructor (public response: http.{{#supportsES6}}IncomingMessage{{/supportsES6}}{{^supportsES6}}ClientResponse{{/supportsES6}}, public body: any, public statusCode?: number) {
constructor (public response: http.IncomingMessage, public body: any, public statusCode?: number) {
super('HTTP request failed');
this.name = 'HttpError';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class {{classname}} {
* @param {{paramName}} {{description}}
{{/allParams}}
*/
public async {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.{{#supportsES6}}IncomingMessage{{/supportsES6}}{{^supportsES6}}ClientResponse{{/supportsES6}}; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> {
public async {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> {
const localVarPath = this.basePath + '{{{path}}}'{{#pathParams}}
.replace('{' + '{{baseName}}' + '}', encodeURIComponent(String({{paramName}}))){{/pathParams}};
let localVarQueryParameters: any = {};
Expand Down Expand Up @@ -261,7 +261,7 @@ export class {{classname}} {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise<{ response: http.{{#supportsES6}}IncomingMessage{{/supportsES6}}{{^supportsES6}}ClientResponse{{/supportsES6}}; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }>((resolve, reject) => {
return new Promise<{ response: http.IncomingMessage; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }>((resolve, reject) => {
localVarRequest(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class PetApi {
*
* @param body Pet object that needs to be added to the store
*/
public addPet (body?: Pet) : Promise<{ response: http.ClientResponse; body?: any; }> {
public addPet (body?: Pet) : Promise<{ response: http.IncomingMessage; body?: any; }> {
const localVarPath = this.basePath + '/pet';
let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders);
Expand Down Expand Up @@ -167,7 +167,7 @@ export class PetApi {
requestOptions.form = formParams;
}
}
return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => {
request(requestOptions, (error, response, body) => {
if (error) {
reject(error);
Expand All @@ -187,7 +187,7 @@ export class PetApi {
* @param petId Pet id to delete
* @param apiKey
*/
public deletePet (petId: number, apiKey?: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
public deletePet (petId: number, apiKey?: string) : Promise<{ response: http.IncomingMessage; body?: any; }> {
const localVarPath = this.basePath + '/pet/{petId}'
.replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {};
Expand Down Expand Up @@ -222,7 +222,7 @@ export class PetApi {
requestOptions.form = formParams;
}
}
return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => {
request(requestOptions, (error, response, body) => {
if (error) {
reject(error);
Expand All @@ -241,7 +241,7 @@ export class PetApi {
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
*/
public getPetById (petId: number) : Promise<{ response: http.ClientResponse; body: Pet; }> {
public getPetById (petId: number) : Promise<{ response: http.IncomingMessage; body: Pet; }> {
const localVarPath = this.basePath + '/pet/{petId}'
.replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {};
Expand Down Expand Up @@ -274,7 +274,7 @@ export class PetApi {
requestOptions.form = formParams;
}
}
return new Promise<{ response: http.ClientResponse; body: Pet; }>((resolve, reject) => {
return new Promise<{ response: http.IncomingMessage; body: Pet; }>((resolve, reject) => {
request(requestOptions, (error, response, body) => {
if (error) {
reject(error);
Expand All @@ -293,7 +293,7 @@ export class PetApi {
*
* @param body Pet object that needs to be added to the store
*/
public updatePet (body?: Pet) : Promise<{ response: http.ClientResponse; body?: any; }> {
public updatePet (body?: Pet) : Promise<{ response: http.IncomingMessage; body?: any; }> {
const localVarPath = this.basePath + '/pet';
let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders);
Expand Down Expand Up @@ -321,7 +321,7 @@ export class PetApi {
requestOptions.form = formParams;
}
}
return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => {
request(requestOptions, (error, response, body) => {
if (error) {
reject(error);
Expand All @@ -342,7 +342,7 @@ export class PetApi {
* @param name Updated name of the pet
* @param status Updated status of the pet
*/
public updatePetWithForm (petId: string, name?: string, status?: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
public updatePetWithForm (petId: string, name?: string, status?: string) : Promise<{ response: http.IncomingMessage; body?: any; }> {
const localVarPath = this.basePath + '/pet/{petId}'
.replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {};
Expand Down Expand Up @@ -383,7 +383,7 @@ export class PetApi {
requestOptions.form = formParams;
}
}
return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => {
request(requestOptions, (error, response, body) => {
if (error) {
reject(error);
Expand Down Expand Up @@ -443,7 +443,7 @@ export class StoreApi {
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* @param orderId ID of the order that needs to be deleted
*/
public deleteOrder (orderId: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
public deleteOrder (orderId: string) : Promise<{ response: http.IncomingMessage; body?: any; }> {
const localVarPath = this.basePath + '/store/order/{orderId}'
.replace('{' + 'orderId' + '}', String(orderId));
let queryParameters: any = {};
Expand Down Expand Up @@ -476,7 +476,7 @@ export class StoreApi {
requestOptions.form = formParams;
}
}
return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => {
request(requestOptions, (error, response, body) => {
if (error) {
reject(error);
Expand All @@ -494,7 +494,7 @@ export class StoreApi {
* Returns pet inventories by status
* Returns a map of status codes to quantities
*/
public getInventory () : Promise<{ response: http.ClientResponse; body: { [key: string]: number; }; }> {
public getInventory () : Promise<{ response: http.IncomingMessage; body: { [key: string]: number; }; }> {
const localVarPath = this.basePath + '/store/inventory';
let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders);
Expand All @@ -521,7 +521,7 @@ export class StoreApi {
requestOptions.form = formParams;
}
}
return new Promise<{ response: http.ClientResponse; body: { [key: string]: number; }; }>((resolve, reject) => {
return new Promise<{ response: http.IncomingMessage; body: { [key: string]: number; }; }>((resolve, reject) => {
request(requestOptions, (error, response, body) => {
if (error) {
reject(error);
Expand All @@ -540,7 +540,7 @@ export class StoreApi {
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched
*/
public getOrderById (orderId: string) : Promise<{ response: http.ClientResponse; body: Order; }> {
public getOrderById (orderId: string) : Promise<{ response: http.IncomingMessage; body: Order; }> {
const localVarPath = this.basePath + '/store/order/{orderId}'
.replace('{' + 'orderId' + '}', String(orderId));
let queryParameters: any = {};
Expand Down Expand Up @@ -573,7 +573,7 @@ export class StoreApi {
requestOptions.form = formParams;
}
}
return new Promise<{ response: http.ClientResponse; body: Order; }>((resolve, reject) => {
return new Promise<{ response: http.IncomingMessage; body: Order; }>((resolve, reject) => {
request(requestOptions, (error, response, body) => {
if (error) {
reject(error);
Expand All @@ -592,7 +592,7 @@ export class StoreApi {
*
* @param body order placed for purchasing the pet
*/
public placeOrder (body?: Order) : Promise<{ response: http.ClientResponse; body: Order; }> {
public placeOrder (body?: Order) : Promise<{ response: http.IncomingMessage; body: Order; }> {
const localVarPath = this.basePath + '/store/order';
let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders);
Expand Down Expand Up @@ -620,7 +620,7 @@ export class StoreApi {
requestOptions.form = formParams;
}
}
return new Promise<{ response: http.ClientResponse; body: Order; }>((resolve, reject) => {
return new Promise<{ response: http.IncomingMessage; body: Order; }>((resolve, reject) => {
request(requestOptions, (error, response, body) => {
if (error) {
reject(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class DefaultApi {
/**
*
*/
public getObjectWithEnums (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array<ObjectWithEnums>; }> {
public getObjectWithEnums (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array<ObjectWithEnums>; }> {
const localVarPath = this.basePath + '/getobjectwithenums';
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
Expand Down Expand Up @@ -101,7 +101,7 @@ export class DefaultApi {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise<{ response: http.ClientResponse; body: Array<ObjectWithEnums>; }>((resolve, reject) => {
return new Promise<{ response: http.IncomingMessage; body: Array<ObjectWithEnums>; }>((resolve, reject) => {
localVarRequest(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
Expand All @@ -120,7 +120,7 @@ export class DefaultApi {
*
* @param objectWithEnums
*/
public postObjectWithEnums (objectWithEnums: ObjectWithEnums, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> {
public postObjectWithEnums (objectWithEnums: ObjectWithEnums, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
const localVarPath = this.basePath + '/postobjectwithenums';
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
Expand Down Expand Up @@ -154,7 +154,7 @@ export class DefaultApi {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => {
localVarRequest(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as fs from 'fs';
import * as http from 'http';

export class HttpError extends Error {
constructor (public response: http.ClientResponse, public body: any, public statusCode?: number) {
constructor (public response: http.IncomingMessage, public body: any, public statusCode?: number) {
super('HTTP request failed');
this.name = 'HttpError';
}
Expand Down
Loading