Im my project, I would like to use
I face an error when deploying. It's easy to reproduce (Now skip firestore and firebase hosting initialization)
yarn create react-app sample-app
cd sample-app
firebase init
(select functions by marking a box interactively)
(select typescript by marking a box interactively)
(uncomment in functions/src/index.ts)
functions/src/index.ts is
import * as functions from 'firebase-functions';
// Start writing Firebase Functions
// https://firebase.google.com/docs/functions/typescript
export const helloWorld = functions.https.onRequest((request, response) => {
functions.logger.info("Hello logs!", {structuredData: true});
response.send("Hello from Firebase!");
});
Then deployment fails
firebase deploy
=== Deploying to 'myproject'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint /Users/username/sample-app/functions
> tslint --project tsconfig.json
Running command: npm --prefix "$RESOURCE_DIR" run build
> functions@ build /Users/username/sample-app/functions
> tsc
../node_modules/@types/testing-library__react/index.d.ts:13:49 - error TS7016: Could not find a declaration file for module '@testing-library/dom'. '/Users/username/sample-app/node_modules/@testing-library/dom/dist/index.js' implicitly has an 'any' type.
Try `npm install @types/testing-library__dom` if it exists or add a new declaration (.d.ts) file containing `declare module '@testing-library/dom';`
13 import { queries, Queries, BoundFunction } from '@testing-library/dom';
~~~~~~~~~~~~~~~~~~~~~~
../node_modules/@types/testing-library__react/index.d.ts:16:15 - error TS7016: Could not find a declaration file for module '@testing-library/dom'. '/Users/username/sample-app/node_modules/@testing-library/dom/dist/index.js' implicitly has an 'any' type.
Try `npm install @types/testing-library__dom` if it exists or add a new declaration (.d.ts) file containing `declare module '@testing-library/dom';`
16 export * from '@testing-library/dom';
~~~~~~~~~~~~~~~~~~~~~~
Found 2 errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions@ build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the functions@ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/username/.npm/_logs/2020-08-04T06_14_06_195Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code2
Even after I did
npm install @types/testing-library__dom
in root and functions/, deployment fails.
and root directory has
ls
README.md firebase.json functions node_modules package.json public src tsconfig.json yarn.lock
Any idea welcome.
Can you try if this solution works for you?
https://stackoverflow.com/a/49309428/1673761
add this line to tsconfig within the functions folder:
{
"compilerOptions": {
...
"typeRoots": [
"node_modules/@types",
],
...
}
This is part of "compilerOptions" block worked for me
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