I have been developing an Ionic Capacitor React app using Typescript and a Firebase backend. That has been working great, but I had problems getting Firebase Functions to build. There was an error in the build process as the tsc compiler through up errors in the node_modules/@types/react/ts5.0/index.d.ts file which is in the main node_modules file of the main project, not the one in the functions directory.
1 Answer
After banging my head with this one for a while trying to figure out to exclude the node_modules directory in both the functions directory and in the main directory, I eventually came across this super simple fix, so I thought I would share with the community.
Add the "types": [] to the compilerOptions in the functions/tsconfig.json file:
"compilerOptions": {
...
"types": []
},
"exclude": [
"node_modules"
]
This tells the compiler to ignore the @types folder in the node_modules. That is even with the node_modules excluded already, this is still needed for some reason.
This fix sorted the build issue and I was able to compile and deploy.