title: Type Assertions not Working when Reading Firestore Data
body: <p>I am trying to read a complex document from Firebase in order to do some calculations and then execute a Cloud Function.</p>
  <p>Unfortunately, I am unable to read the data in the data types that I would like.</p>
  <p>Here is an example:</p>
  <pre><code>interface CourseEvent {
    coucourseGroupType: string;
    date: FirebaseFirestore.Timestamp;
    courseGroupTypeFirebaseId: string;
    firebaseId: string;
    maxParticipants: number;
    participants: Participant[];
    start: FirebaseFirestore.Timestamp;
    waitingList: Participant[];
    weekNumber: string;
  }
  </code></pre>
  <p>This is where I am using the Cloud Function</p>
  <pre><code>import * as functions from &quot;firebase-functions&quot;;
  import { firestore, Timestamp, FieldValue } from &quot;./setup&quot;;
  
  export const registerCustomerFromWaitingList = functions.firestore
    .document(&quot;CourseEvents/{courseEvent}&quot;)
    .onUpdate(async (change, context) =&gt; {
      const currentCourseEvent = change.after.data() as CourseEvent;
      const currentMaxParticipants = currentCourseEvent.maxParticipants;
      if (typeof currentMaxParticipants === &quot;number&quot;) {
       console.log(`currentMaxParticipants type is number`);
      } else if (typeof currentMaxParticipants === &quot;string&quot;) {
       console.log(`currentMaxParticipants type is string`);
      } else {
       console.log(`currentMaxParticipants type is NOT number or string`);
      }
     }
  </code></pre>
  <p>The console always prints that the <code>currentMaxParticipants </code> is a <strong>string</strong>. I have a similar problem also with another interface.</p>
  <p>I also have experimented with such code</p>
  <pre><code>const nu = change.after.data().maxParticipants as number;
  </code></pre>
  <p>But in the end, I am still getting a string.</p>
  <p>Any tips?</p>