draftbit / twitter-lite

A tiny, full-featured, flexible client / server library for the Twitter API
https://npm.im/twitter-lite
MIT License
794 stars 95 forks source link

Update types to allow either app or user auth #113

Open PascalHelbig opened 4 years ago

PascalHelbig commented 4 years ago

Initializing a new client with App authentication creates an TypeScript error:

new Twitter({ bearer_token: 'abc' });
Argument of type '{ bearer_token: string; }' is not assignable to parameter of type 'TwitterOptions'.
  Type '{ bearer_token: string; }' is missing the following properties from type 'TwitterOptions': consumer_key, consumer_secret

With this PR TwitterOptions accepts either the fields for User authentication (consumer_key, consumer_secret, access_token_key, access_token_secret) or for App authentication (bearer_token) as described in the README.