How to avoid typescript error: Property 'innerHTML' does not exist on type 'Element'

Use a type assertion to placate the compiler:

let myContainer = <HTMLElement> document.querySelector("#myDiv");
myContainer.innerHTML = '<h1>Test</h1>';

In future versions of TypeScript, it should not be necessary to do the casting. I've sent a pull request to fix the issue:

  • error: Property 'innnerHTML' does not exist on type 'Element' (https://github.com/Microsoft/TypeScript/issues/5754)
  • https://github.com/Microsoft/TSJS-lib-generator/pull/35 (merged already)