npm ライブラリを install して tsc したらこんなエラーが大量に出た。
node_modules/@google-cloud/firestore/types/firestore.d.ts(28,15): error TS2300: Duplicate identifier 'DocumentData'. node_modules/@google-cloud/firestore/types/firestore.d.ts(35,15): error TS2300: Duplicate identifier 'UpdateData'. ...略 node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts(28,15): error TS2300: Duplicate identifier 'DocumentData'. node_modules/firebase-admin/node_modules/@google-cloud/firestore/types/firestore.d.ts(35,15): error TS2300: Duplicate identifier 'UpdateData'. ...略
解決策を先に言うと npm から yarn に乗り換えたらこのエラーが出なくなった。
$ rm packege-lock.json $ rm -rf node_modules $ npm i -g yarn $ yarn $ yarn run build # tsc する
これだけで解決した。
原因
依存関係が Duplicate してしまっていたぽい。
みたいに @google-cloud/firestore が2箇所から呼ばれて、それを npm がうまく解決できずどちらも install してしまい、その中に型定義があるため型定義が2回呼ばれて Duplicate identifier
になっていたっぽい。
社の若者に「そのエラーつらそうだけど yarn にしたら治りそう」という助言をもらって yarn にしたら解決した。
yarn の方が賢いっぽい。