title: Typescript error: Property is used before being assigned
body: <p>Typescript shows <strong>[ts] Property 'logger' is used before being assigned</strong> in VSCode. The error occurs in code below at <code>this.logger.logInfo(Important, ...</code>. I'm very clearly setting this property on second line of the constructor so...?</p>
  
  <p>If I used the <code>self</code> var shown in code (self.logger.logInfo...), the TS error goes away but this should not be necessary.</p>
  
  <p>Thank you for sharing your expertise :-)</p>
  
  <pre><code>// app/data/mongo/_base.data.mongo.ts 
  
  import { MongoClient, ObjectId } from 'mongodb';
  import { IBaseModel } from '../../model/_base.model';
  import { Logger, Important, NotImportant } from '../../util/logger';
  
  export default class BaseData {
  
      constructor(params: any) {
          this.collectionName = params.collectionName;
          this.logger = new Logger(this.collectionName);
          if (this.db) {
              this.collection = this.db.getCollection(this.collectionName);
          } else {
              BaseData.userId = params.user.id;
              BaseData.userHandle = params.user.handle;
              this.dbServer = params.dbServer;
              this.dbPort = params.dbPort || '27017';
              this.dbName = params.dbName;
              const self = this; // This is a Typescript BUG!
              (async () =&gt; {
                  const url = `mongodb://${this.dbServer}:${this.dbPort}`;
                  this.db = await MongoClient.connect(url, { "useNewUrlParser": true });
                  this.collection = this.db.collection(this.collectionName);
                  this.logger.logInfo(Important, 'contructor', `MongoDb connection (${url}) success!`);
              })();
          }
      }
  
      static userId: string;
      static userHandle: string;
  
      protected logger: Logger;
      protected collectionName: string = '';
      protected client: any;
      protected collection: any;
      protected db: any;
      protected dbServer: string = '';
      protected dbPort: string = '';
      protected dbName: string = '';
  </code></pre>