|
1 | | -import TwitterApi from '.'; |
| 1 | +import type TwitterApi from '.'; |
2 | 2 | import TwitterApiBase from '../client.base'; |
3 | 3 | import { |
4 | 4 | AccessOAuth2TokenArgs, |
@@ -151,7 +151,7 @@ export default class TwitterApiReadOnly extends TwitterApiBase { |
151 | 151 | { oauth_token: tokens.accessToken, oauth_verifier } |
152 | 152 | ); |
153 | 153 |
|
154 | | - const client = new TwitterApi({ |
| 154 | + const client = new (this.constructor as typeof TwitterApi)({ |
155 | 155 | appKey: tokens.appKey, |
156 | 156 | appSecret: tokens.appSecret, |
157 | 157 | accessToken: oauth_result.oauth_token, |
@@ -185,11 +185,11 @@ export default class TwitterApiReadOnly extends TwitterApiBase { |
185 | 185 | throw new Error('You must setup TwitterApi instance with consumer keys to accept app-only login'); |
186 | 186 |
|
187 | 187 | // Create a client with Basic authentication |
188 | | - const basicClient = new TwitterApi({ username: tokens.appKey, password: tokens.appSecret }, this._requestMaker.clientSettings); |
| 188 | + const basicClient = new (this.constructor as typeof TwitterApi)({ username: tokens.appKey, password: tokens.appSecret }, this._requestMaker.clientSettings); |
189 | 189 | const res = await basicClient.post<BearerTokenResult>('https://api.x.com/oauth2/token', { grant_type: 'client_credentials' }); |
190 | 190 |
|
191 | 191 | // New object with Bearer token |
192 | | - return new TwitterApi(res.access_token, this._requestMaker.clientSettings); |
| 192 | + return new (this.constructor as typeof TwitterApi)(res.access_token, this._requestMaker.clientSettings); |
193 | 193 | } |
194 | 194 |
|
195 | 195 | /* OAuth 2 user authentication */ |
@@ -356,7 +356,7 @@ export default class TwitterApiReadOnly extends TwitterApiBase { |
356 | 356 | } |
357 | 357 |
|
358 | 358 | protected parseOAuth2AccessTokenResult(result: AccessOAuth2TokenResult): IParsedOAuth2TokenResult { |
359 | | - const client = new TwitterApi(result.access_token, this._requestMaker.clientSettings); |
| 359 | + const client = new (this.constructor as typeof TwitterApi)(result.access_token, this._requestMaker.clientSettings); |
360 | 360 | const scope = result.scope.split(' ').filter(e => e) as TOAuth2Scope[]; |
361 | 361 |
|
362 | 362 | return { |
|
0 commit comments