title: TypeScript: 'number | undefined' is not assignable to parameter of type 'number'
body: <p>I have a model with Activiy Interface and Mongo Schema, and a function that takes an ID and logs it.
  Then in my route I'm querying all activities from a given customer where the externalId is not undefined. With the returned array I call that function defined in my model, passing externalId as param.</p>
  
  <p>But TypeScript keeps throwing: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. Type 'undefined' is not assignable to type 'number'.
  I already tried to wrap the call with an if statement checking if <code>externalId &amp;&amp; typeof externalId === 'number'</code>, but I can't make the error go away.</p>
  
  <p>Model:</p>
  
  <pre><code>import { Schema, model, } from 'mongoose';
  
  interface IActivity {
      customer: string,
      externalId?: number,
  }
  
  const activitySchema: Schema = new Schema({
      Customer: {
          type: String,
          required: true,
          minlength: 5,
          maxlength: 50,
      },
      externalId: { type: Number, },
  });
  
  export function updateExternal(externalId: number): void {
      console.log(externalId);
  }
  
  export const Activity = model&lt;IActivityModel&gt;('Activity', activitySchema);
  </code></pre>
  
  <p>Route:</p>
  
  <pre><code>const completeActivity = await Activity
      .find({
          'externalId': { '$ne': undefined, },
          'customer': 'Foo Customer',
      });
  
  completeActivity.forEach((activity) =&gt; {
       updateExternal(activity.externalId); // This is where the error appears
  });
  </code></pre>