I have two projects with similar Cloud Functions setup, both directly using Typescript setup (no Webpack) similar to this example or this one
One of them uses Firestore, other one doesn't. The one that does not use Firestore compiles and deploys with no error.
However the one with Firestore functions gives me this error on tsc compile:
../node_modules/@types/googlemaps/index.d.ts(33,29): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(37,19): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(54,28): error TS2304: Cannot find name 'Node'.
../node_modules/@types/googlemaps/index.d.ts(787,30): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(798,36): error TS2304: Cannot find name 'Node'.
../node_modules/@types/googlemaps/index.d.ts(811,26): error TS2304: Cannot find name 'Node'.
../node_modules/@types/googlemaps/index.d.ts(1135,20): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1136,22): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1137,18): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1138,22): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1139,23): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1140,23): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1141,29): error TS2304: Cannot find name 'Element'.
... and goes on.
These are package.json dependencies:
"dependencies": {
"@google-cloud/storage": "^1.5.0",
"axios": "^0.17.1",
"child-process-promise": "^2.2.1",
"firebase-admin": "~5.5.1",
"firebase-functions": "^0.7.3"
},
"devDependencies": {
"typescript": "^2.6.2"
},
and content of the tsconfig:
{
"compilerOptions": {
"lib": ["es6", "es2015.promise"],
"module": "commonjs",
"noImplicitAny": false,
"outDir": "build",
"sourceMap": true,
"target": "es6"
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
]
}
What am I missing? Is it related to Typescript version? (2.6) Do I need to import a @types? Adding dev-dependency @types/node did not help.
At first I thought problem was exclusion of node_modules folder in tsconfig file and removed "exclude": [ "node_modules" ] part. It did not help.
Then since all errors seems to be related to DOM element names or "Node", it should be about a missing types definition of some general package, hence did another search on that matter and run into this answer of a similar question: Typescript build getting errors from node_modules folder
Changing tsconfig like this (adding reference to lib.es6.d.ts) make my problem go away:
"include": [
"src/**/*.ts"
],
"files": [
"node_modules/typescript/lib/lib.es6.d.ts"
],
"exclude": [
"node_modules"
]
Adding
"skipLibCheck": true to tsconfig.json also does the trick.
credit - https://github.com/firebase/firebase-tools/issues/749#issuecomment-385693352
I had this issue with Firebase functions project. FULL solution for:
node_modules/@google-cloud/firestore/types/firestore.d.ts:1629:8 - error TS2304: Cannot find name 'AsyncIterable'.
npm install -g npm-check-updates
/functions and run this in cmd: ncu -u
Here you'll see something like this:firebase-admin ^9.2.0 → ^9.5.0 firebase-functions ^3.11.0 → ^3.13.1 googleapis ^40.0.0 → ^67.0.0 typescript ^3.8.0 → ^4.1.5 firebase-functions-test ^0.2.0 → ^0.2.3
npm install
lib compiler option to 'es2018' or later.
functions/tsconfig.json and update value for target node as it says in error text, in my case I updated to es2018 and deploy should be run finep.s. Don't forget to save each change, just Ctrl+S ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With