From d06f7f8ee0129955b3e924bd4117a31deccc21bd Mon Sep 17 00:00:00 2001 From: Pascal Helbig Date: Thu, 18 Jun 2020 09:28:17 +0200 Subject: [PATCH] Update types to allow either app or user auth --- index.d.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index d3151f4..3a36c61 100644 --- a/index.d.ts +++ b/index.d.ts @@ -117,11 +117,16 @@ export default class Twitter { Currently Twitter themselves convert it to strings for the API though, so this change will come some time in the far future. */ type snowflake = string; -interface TwitterOptions { +type TwitterOptions = TwitterOptionsUserAuthentication | TwitterOptionsAppAuthentication + +interface TwitterOptionsBasics { /** "api" is the default (change for other subdomains) */ subdomain?: string; /** version "1.1" is the default (change for other subdomains) */ version?: string; +} + +interface TwitterOptionsUserAuthentication extends TwitterOptionsBasics { /** consumer key from Twitter. */ consumer_key: string; /** consumer secret from Twitter */ @@ -131,7 +136,20 @@ interface TwitterOptions { /** access token secret from your User (oauth_token_secret) */ access_token_secret?: OauthTokenSecret; /** bearer token */ - bearer_token?: string; + bearer_token?: never; +} + +interface TwitterOptionsAppAuthentication extends TwitterOptionsBasics { + /** consumer key from Twitter. */ + consumer_key?: never; + /** consumer secret from Twitter */ + consumer_secret?: never; + /** access token key from your User (oauth_token) */ + access_token_key?: never; + /** access token secret from your User (oauth_token_secret) */ + access_token_secret?: never; + /** bearer token */ + bearer_token: string; } type OauthToken = string;