forked from loafle/openapi-generator-original
[typescript-rxjs] restore prototype inheritance for clone & its clients (#6001)
* [typescript-rxjs] restore prototype inhertance - previously clone() and its clients in the BaseAPI class were generic - with removal of the generic argument, these methods became unavailable to the API classes inheriting from BaseAPI - original generic was imprecise, as these are not statics - return type of `this` is the correct notation * [typescript-rxjs] Chery-pick from #5465 by @denyo - this is done to prevent the changes slated for 5.0 from conflicting - apply destructuring changes from - denyo:feature/rxjs-statuscode-and-progress@673d67c
This commit is contained in:
parent
d92b8833b0
commit
2f9aa282e5
@ -35,7 +35,7 @@ export class Configuration {
|
||||
}
|
||||
|
||||
get apiKey(): ((name: string) => string) | undefined {
|
||||
const apiKey = this.configuration.apiKey;
|
||||
const { apiKey } = this.configuration;
|
||||
if (!apiKey) {
|
||||
return undefined;
|
||||
}
|
||||
@ -43,7 +43,7 @@ export class Configuration {
|
||||
}
|
||||
|
||||
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
||||
const accessToken = this.configuration.accessToken;
|
||||
const { accessToken } = this.configuration;
|
||||
if (!accessToken) {
|
||||
return undefined;
|
||||
}
|
||||
@ -61,7 +61,7 @@ export class BaseAPI {
|
||||
this.middleware = configuration.middleware;
|
||||
}
|
||||
|
||||
withMiddleware = (middlewares: Middleware[]) => {
|
||||
withMiddleware = (middlewares: Middleware[]): this => {
|
||||
const next = this.clone();
|
||||
next.middleware = next.middleware.concat(middlewares);
|
||||
return next;
|
||||
@ -121,7 +121,7 @@ export class BaseAPI {
|
||||
* Create a shallow clone of `this` by constructing a new instance
|
||||
* and then shallow cloning data members.
|
||||
*/
|
||||
private clone = (): BaseAPI =>
|
||||
private clone = (): this =>
|
||||
Object.assign(Object.create(Object.getPrototypeOf(this)), this);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ export class Configuration {
|
||||
}
|
||||
|
||||
get apiKey(): ((name: string) => string) | undefined {
|
||||
const apiKey = this.configuration.apiKey;
|
||||
const { apiKey } = this.configuration;
|
||||
if (!apiKey) {
|
||||
return undefined;
|
||||
}
|
||||
@ -54,7 +54,7 @@ export class Configuration {
|
||||
}
|
||||
|
||||
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
||||
const accessToken = this.configuration.accessToken;
|
||||
const { accessToken } = this.configuration;
|
||||
if (!accessToken) {
|
||||
return undefined;
|
||||
}
|
||||
@ -72,7 +72,7 @@ export class BaseAPI {
|
||||
this.middleware = configuration.middleware;
|
||||
}
|
||||
|
||||
withMiddleware = (middlewares: Middleware[]) => {
|
||||
withMiddleware = (middlewares: Middleware[]): this => {
|
||||
const next = this.clone();
|
||||
next.middleware = next.middleware.concat(middlewares);
|
||||
return next;
|
||||
@ -132,7 +132,7 @@ export class BaseAPI {
|
||||
* Create a shallow clone of `this` by constructing a new instance
|
||||
* and then shallow cloning data members.
|
||||
*/
|
||||
private clone = (): BaseAPI =>
|
||||
private clone = (): this =>
|
||||
Object.assign(Object.create(Object.getPrototypeOf(this)), this);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ export class Configuration {
|
||||
}
|
||||
|
||||
get apiKey(): ((name: string) => string) | undefined {
|
||||
const apiKey = this.configuration.apiKey;
|
||||
const { apiKey } = this.configuration;
|
||||
if (!apiKey) {
|
||||
return undefined;
|
||||
}
|
||||
@ -54,7 +54,7 @@ export class Configuration {
|
||||
}
|
||||
|
||||
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
||||
const accessToken = this.configuration.accessToken;
|
||||
const { accessToken } = this.configuration;
|
||||
if (!accessToken) {
|
||||
return undefined;
|
||||
}
|
||||
@ -72,7 +72,7 @@ export class BaseAPI {
|
||||
this.middleware = configuration.middleware;
|
||||
}
|
||||
|
||||
withMiddleware = (middlewares: Middleware[]) => {
|
||||
withMiddleware = (middlewares: Middleware[]): this => {
|
||||
const next = this.clone();
|
||||
next.middleware = next.middleware.concat(middlewares);
|
||||
return next;
|
||||
@ -132,7 +132,7 @@ export class BaseAPI {
|
||||
* Create a shallow clone of `this` by constructing a new instance
|
||||
* and then shallow cloning data members.
|
||||
*/
|
||||
private clone = (): BaseAPI =>
|
||||
private clone = (): this =>
|
||||
Object.assign(Object.create(Object.getPrototypeOf(this)), this);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ export class Configuration {
|
||||
}
|
||||
|
||||
get apiKey(): ((name: string) => string) | undefined {
|
||||
const apiKey = this.configuration.apiKey;
|
||||
const { apiKey } = this.configuration;
|
||||
if (!apiKey) {
|
||||
return undefined;
|
||||
}
|
||||
@ -54,7 +54,7 @@ export class Configuration {
|
||||
}
|
||||
|
||||
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
||||
const accessToken = this.configuration.accessToken;
|
||||
const { accessToken } = this.configuration;
|
||||
if (!accessToken) {
|
||||
return undefined;
|
||||
}
|
||||
@ -72,7 +72,7 @@ export class BaseAPI {
|
||||
this.middleware = configuration.middleware;
|
||||
}
|
||||
|
||||
withMiddleware = (middlewares: Middleware[]) => {
|
||||
withMiddleware = (middlewares: Middleware[]): this => {
|
||||
const next = this.clone();
|
||||
next.middleware = next.middleware.concat(middlewares);
|
||||
return next;
|
||||
@ -132,7 +132,7 @@ export class BaseAPI {
|
||||
* Create a shallow clone of `this` by constructing a new instance
|
||||
* and then shallow cloning data members.
|
||||
*/
|
||||
private clone = (): BaseAPI =>
|
||||
private clone = (): this =>
|
||||
Object.assign(Object.create(Object.getPrototypeOf(this)), this);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ export class Configuration {
|
||||
}
|
||||
|
||||
get apiKey(): ((name: string) => string) | undefined {
|
||||
const apiKey = this.configuration.apiKey;
|
||||
const { apiKey } = this.configuration;
|
||||
if (!apiKey) {
|
||||
return undefined;
|
||||
}
|
||||
@ -54,7 +54,7 @@ export class Configuration {
|
||||
}
|
||||
|
||||
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
||||
const accessToken = this.configuration.accessToken;
|
||||
const { accessToken } = this.configuration;
|
||||
if (!accessToken) {
|
||||
return undefined;
|
||||
}
|
||||
@ -72,7 +72,7 @@ export class BaseAPI {
|
||||
this.middleware = configuration.middleware;
|
||||
}
|
||||
|
||||
withMiddleware = (middlewares: Middleware[]) => {
|
||||
withMiddleware = (middlewares: Middleware[]): this => {
|
||||
const next = this.clone();
|
||||
next.middleware = next.middleware.concat(middlewares);
|
||||
return next;
|
||||
@ -132,7 +132,7 @@ export class BaseAPI {
|
||||
* Create a shallow clone of `this` by constructing a new instance
|
||||
* and then shallow cloning data members.
|
||||
*/
|
||||
private clone = (): BaseAPI =>
|
||||
private clone = (): this =>
|
||||
Object.assign(Object.create(Object.getPrototypeOf(this)), this);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user