Skip to content

Commit 92520f5

Browse files
committed
fix: remove circular import in TwitterApiReadOnly
1 parent 7d51f7b commit 92520f5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/client/readonly.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import TwitterApi from '.';
1+
import type TwitterApi from '.';
22
import TwitterApiBase from '../client.base';
33
import {
44
AccessOAuth2TokenArgs,
@@ -151,7 +151,7 @@ export default class TwitterApiReadOnly extends TwitterApiBase {
151151
{ oauth_token: tokens.accessToken, oauth_verifier }
152152
);
153153

154-
const client = new TwitterApi({
154+
const client = new (this.constructor as typeof TwitterApi)({
155155
appKey: tokens.appKey,
156156
appSecret: tokens.appSecret,
157157
accessToken: oauth_result.oauth_token,
@@ -185,11 +185,11 @@ export default class TwitterApiReadOnly extends TwitterApiBase {
185185
throw new Error('You must setup TwitterApi instance with consumer keys to accept app-only login');
186186

187187
// 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);
189189
const res = await basicClient.post<BearerTokenResult>('https://api.x.com/oauth2/token', { grant_type: 'client_credentials' });
190190

191191
// 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);
193193
}
194194

195195
/* OAuth 2 user authentication */
@@ -356,7 +356,7 @@ export default class TwitterApiReadOnly extends TwitterApiBase {
356356
}
357357

358358
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);
360360
const scope = result.scope.split(' ').filter(e => e) as TOAuth2Scope[];
361361

362362
return {

0 commit comments

Comments
 (0)