question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript compilation error: Argument of type 'Express' is not assignable [..]

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:22
  • Comments:23

github_iconTop GitHub Comments

11reactions
jpinilloslrcommented, Apr 17, 2020

Same issue with firebase-functions 3.6.0.

5reactions
kossnocorpcommented, Apr 12, 2020

I’ve upgraded to firebase-functions from 3.3.0 to 3.6.0 and now also have this issue. I managed to fix it with any, but it’s not ideal.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found