Typescript cannot find name window or document
<p>For either case:</p>

<pre><code>document.getElementById('body');
// or
window.document.getElementById('body');
</code></pre>

<p>I get <code>error TS2304: Cannot find name 'window'.</code></p>

<p>Am I missing something in <code>tsconfig.json</code> for a definition file I should install?</p>

<p>I get the message when running <code>tsc</code> and in <code>vscode</code></p>

<p>tsconfig.json:</p>

<pre><code>{
    "compilerOptions": {
        "allowJs": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "jsx": "react",
        "module": "commonjs",
        "moduleResolution": "node",
        "noEmitOnError": true,
        "noImplicitAny": false,
        "sourceMap": true,
        "suppressImplicitAnyIndexErrors": true,
        "target": "ES2016",
        "typeRoots": [
            "node_modules/@types/",
            "typings/index.d.ts"
        ]
    },
    "exclude": [
        "node_modules",
        "**/*-aot.ts"
    ]
}
</code></pre>

<p>My Answer:
For use with <code>tsconfig.json</code> I target <code>es5</code> and use <code>lib: ["es2015", "dom"]</code></p>