title: Typescript: Cannot find namespace
body: <p>I have the following simple NodeJS code:</p>
  
  <pre><code>const express = require('express');
  
  const server: express.Application = express();
  </code></pre>
  
  <p>I'm adding Typescript to my project and am new to it so forgive me. With the above code I get the following issues/errors:</p>
  
  <p>For the require:</p>
  
  <pre><code>var require: NodeRequire (id: string) =&gt; any (+1 overload)
  'require' call may be converted to an import.
  </code></pre>
  
  <p>For the express.Application usage:</p>
  
  <pre><code>Cannot find namespace 'express'.
  </code></pre>
  
  <p>If I switch the 'require' to 'import' it fixes the namespace error but is no longer valid Node code so doesn't run (throws a new error about unexpected token for the import).</p>
  
  <p>What's the correct way to write Node code like this with Typescript to avoid these errors?</p>
  
  <p>My tsconfig.json looks like this:</p>
  
  <pre><code>{
    "compilerOptions": {
      "allowJs": true,
      "allowSyntheticDefaultImports": true,
      "alwaysStrict": true,
      "esModuleInterop": true,
      "forceConsistentCasingInFileNames": true,
      "jsx": "preserve",
      "lib": ["dom", "es2017"],
      "module": "esnext",
      "moduleResolution": "node",
      "noEmit": true,
      "noFallthroughCasesInSwitch": true,
      "noImplicitReturns": true,
      "noUnusedLocals": true,
      "noUnusedParameters": true,
      "removeComments": true,
      "resolveJsonModule": true,
      "sourceMap": true,
      "strict": true,
      "target": "esnext",
    },
    "exclude": ["node_modules"],
  }
  </code></pre>