Typescript compilation error: Argument of type 'Express' is not assignable [..]
See original GitHub issueVersion 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.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:22
- Comments:23
Top Results From Across the Web
Express errors with typescript - Stack Overflow
I always used helmet and express.json like this, but recently I started seeing these typescript errors. Does anyone know how to fix these?...
Read more >Documentation - Everyday Types - TypeScript
None of the following lines of code will throw compiler errors. ... Argument of type 'number' is not assignable to parameter of type...
Read more >argument of type 'typeof configservice' is not assignable to ...
Since you havn't given this a type, typescript has to try to infer it. It sees you passed in a null, so it...
Read more >Overview - TypeScript
Returns a 'number | string'. f("apple"); // error - Argument of type '"red"' is not assignable to parameter of type '"orange"'. f("red"); ...
Read more >4. Functions - Programming TypeScript [Book] - O'Reilly
add ( 1 , 'a' ) // Error TS2345: Argument of type '"a"' is not assignable // to parameter of type 'number'. Optional...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.