title: Typescript default property value style guide
body: <p>Is there any style guide defining how to set default property values? Hopefully official.</p>
  
  <pre><code>class MyClass {
      public foo = 'asdf';
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>class MyClass {
      public foo: string;
      constructor() {
          this.foo = 'asdf';
      }
  }
  </code></pre>
  
  <p>both compile to</p>
  
  <pre><code>var MyClass = /** @class */ (function () {
      function MyClass() {
          this.foo = 'asdf';
      }
      return MyClass;
  }());
  </code></pre>
  
  <p>The first is cleaner and similar to C# but the second is closer to the syntax of the compiled output ( and definition file if created) and the property type is explicit.</p>
  
  <p>I've looked at <a href="https://www.typescriptlang.org/docs/home.html" rel="nofollow noreferrer">https://www.typescriptlang.org/docs/home.html</a>, <a href="https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines" rel="nofollow noreferrer">https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines</a>, and <a href="https://angular.io/guide/styleguide" rel="nofollow noreferrer">https://angular.io/guide/styleguide</a></p>