title: how to use Twit's Typescript definitions; Callback function not assignable
body: <p>I'm just getting started into Node and typescript. I'm an experienced Java engineer and have done front end work, but it's been mostly copy-paste-modify without fully understanding all the javascript. Now I'm trying to get deeper into Node, JS and Typescript, and think I have jumped too far ahead without understanding what all is going on.  This is just a small personal project. I would like to use classes and liked what TS offered but it seems to introduce more complexity and problems than it solved, so maybe it's not worth it.</p>
  <p>I'm trying to use the Twit package to just read tweets. Had it working fine in plain js before trying to convert it to TS. This was my working js:</p>
  <pre><code>var _ = require('lodash');
  
  var Twit = require('twit');
  
  var T = new Twit({
      consumer_key:         '..'
    , consumer_secret:      '..'
    , access_token:         '..'
    , access_token_secret:  '..'
  })
  
  var options = { screen_name: 'TwitterUser',
                  count: 200 };
  
  T.get('statuses/user_timeline', options , function(err, data) {
    // it comes latest first; I want earliest first
    data.reverse();
    console.log(data[0]);
  
    // try to filter out alerts only
    var alerts = _.filter(data, function(tweet){
      return (tweet.text.indexOf('#alert') &gt; -1) ||
            (tweet.text.indexOf('#ALERT') &gt; -1);
    });
  
    for (var i = 0; i &lt; alerts.length ; i++) {
      console.log(alerts[i].created_at + '  ' + alerts[i].text);
    }
  })
  </code></pre>
  <p>here is the Typescript version:</p>
  <pre><code>import { IncomingMessage } from &quot;http&quot;;
  import _ from &quot;lodash&quot;;
  import Twit from &quot;twit&quot;;
  
  export class TwitterListener {
  
      getlatestTweets() {
          const T = new Twit({
              consumer_key:         '..'
            , consumer_secret:      '..'
            , access_token:         '..'
            , access_token_secret:  '..'
          })
  
          const options = { screen_name: 'TwitterUser',
                  count: 200 };
  
          T.get('statuses/user_timeline', options, function(err, result: Response, data: IncomingMessage) {
              // it comes latest first; I want earliest first
              data.reverse();
              console.log(data[0]);
              
              // try to filter out alerts only
              const alerts = _.filter(data, function(tweet: Twit.Twitter.Status) {
                  return (tweet.text.indexOf('#alert') &gt; -1) ||
                      (tweet.text.indexOf('#ALERT') &gt; -1);
              });
              
              for (let i = 0; i &lt; alerts.length ; i++) {
                  console.log(alerts[i].created_at + '  ' + alerts[i].text);
              }
          })
      }
  }
  </code></pre>
  <p>The biggest problem is on the callback for the get user timeline. The VS Code linter says 'Argument of type (whatever I've tried) is not assignable to parameter of type Callback. The Type Docs at <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/twit/index.d.ts" rel="nofollow noreferrer">DefinitelyTyped</a> say this should be a Callback like so:</p>
  <pre><code>export interface Callback {
      (err: Error, result: Response, response: IncomingMessage): void;
  }
  </code></pre>
  <p>Which is why I tried to change it to that. I thought from the plain js version where the callback is <code>function(err, data)</code> and data is an array of tweets/Statuses that it might be something like <code>function(err:Error, data: any[])</code> or <code>function(err, data: Array&lt;Twit.Twitter.Status&gt;)</code>, which I also tried, but got the same error. I have a feeling it's the syntax of how I'm defining this callback function, but can't figure out what.</p>
  <p>I don't understand how the callback definition goes from <code>function(err, data)</code> to the Callback type with the result and response. What am I missing?</p>