TypeScriptのコンパイル時に『Cannot find name 'EventListenerOrEventListenerObject'.』と怒られる

Firebase Cloud FunctionsをTSで書いて使おうとしていて $ firebase init functions したあとにとりあえずHello Worldしようと思ってハマった。

以下のgetting-startedをのindex.tsをコピーして

github.com

$ firebase deploy --only functions

したところtscコンパイルでいきなりエラーが出てしまった。

node_modules/@types/history/DOMUtils.d.ts:2:78 - error TS2304: Cannot find name 'EventListenerOrEventListenerObject'.

こう怒られる

../node_modules/@types/react-dom/index.d.ts:19:72 - error TS2304: Cannot find name 'Text'.

加えてこうも怒られる

解決手段

tsconfig.json"lib""dom"を足す

こんな感じ

{
  "compilerOptions": {
    "lib": ["es6","dom"], ← "dom"を足す
    "module": "commonjs",
    "noImplicitReturns": true,
    "outDir": "lib",
    "sourceMap": true,
    "target": "es6"
  },
  "compileOnSave": true,
  "include": [
    "src"
  ]
}
参考情報