firebase-functions: Typescript compilation error: Argument of type 'Express' is not assignable [..]
Version info
node v10.16.0
firebase-functions: ^3.3.0
firebase-tools: 7.8.1
express ^4.17.1
Test case
import * as functions from 'firebase-functions';
import * as express from 'express';
const app = express();
export const api = functions.https.onRequest(app);
Steps to reproduce
Add the test case in an Typescript enable environment
Expected behavior
The onRequest
handler should not throw Typescript compilation errors
Actual behavior
Typescript compilation error:
error TS2345: Argument of type 'Express' is not assignable to parameter of type '(req: Request, resp: Response) => void'.
Types of parameters 'req' and 'req' are incompatible.
Were you able to successfully deploy your functions?
Yes, when I ignore typescript by casting it as <any>
it deploys and runs as expected:
export const api = functions.https.onRequest(<any>app);
This is only a typing issue.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 22
- Comments: 24 (1 by maintainers)
Same issue with firebase-functions 3.6.0.
I’ve upgraded to
firebase-functions
from3.3.0
to3.6.0
and now also have this issue. I managed to fix it withany
, but it’s not ideal.I have fixed my firebase import to 3.3.0 in packages.json.
"firebase-functions": "3.3.0",
followed by a
npm update
solved it for now. But this is confirmed an issue with the ^3.6.0 version.After some research, installing “@types/node”: “^14.0.1” solve the problem for me. Be careful to install this specific version, I’ve tried with the latest versions but seems like doing nothing. I’m serving Express on Cloud Functions to SSR and my package.json looks like the following:
Same issue with firebase-functions 3.7.0
Still seeing this with
firebase-functions
3.7.0. Really wanting to update for the Node 10 improvements (considering all the Google libraries rapidly dropping support for Node 8 😅)Does anyone have any new discoveries that could point us in a direction for where to start looking to get this fixed?
OK. I try several times remove node_modules folder and package-lock.json. Have no idea why but now it works. Probably I did some mistake with removing and install updated package.json .