title: How to declare a nullable object literal variable in Typescript?
body: <p>In typescript 2.2, when <a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html" rel="nofollow noreferrer">strictNullChecks</a> option is true, how to declare a nullable object literal variable :</p>
  
  <pre><code>let myVar = { a: 1, b: 2 };
  myVar = null; // Error can not assign null
  </code></pre>
  
  <p>The only ways I found is :</p>
  
  <pre><code>// Verbose
  let myVar: { a: number; b: number; } | null  = { a: 1, b: 2 };
  
  // Bad, same as having no type
  let myVar: any| null  = { a: 1, b: 2 };
  </code></pre>