-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript: functions.https.onRequest() res mismatched type with cors middleware res #713
Comments
@mikgross I am seeing similar issues since upgrading my firebase-functions version. Did you manage to resolve this? |
similar issue here |
Hey there, this is an issue we'll need to look at.
|
Thanks for the workaround. Will definitly try it! |
I dove into the code and think I may see the bug. We have
which seems right. Except that express.Request is a generic interface. By extending |
Believe we have the same issue, is this still a known problem? |
Yes. It's a low priority since a cast does the trick. Internal bug #209905562 |
But also super annoying for someone trying to figure out why types are all over the place until finally landing on this thread. Not only that you're bypassing type safety by doing so .. especially if something is changed firebase later on (which seems to be common with Google) ... no wonder all the examples are in javascript and not typescript To completely bypass type safety as suggested above: // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
onRequest(async (request: any, response: any) => {
request = request as Request;
response = response as Response;
...
} |
Related issues
[REQUIRED] Version info
node:
10
firebase-functions:
3.7
firebase-tools:
7.5
firebase-admin:
8.6
[REQUIRED] Test case
[REQUIRED] Steps to reproduce
run deploy command
firebase deploy --only functions
[REQUIRED] Expected behavior
Correctly deploys my function
[REQUIRED] Actual behavior
The deploy fails, because of type Repsonse from functions doesn't match with type Response expected by CORS: Argument of type 'Response' is not assignable to parameter of type 'Response'.
Type 'Response' is missing the following properties from type 'Response': status, sendStatus, links, send, and 70 more.
Were you able to successfully deploy your functions?
error TS2345: Argument of type 'Response' is not assignable to parameter of type 'Response'.
The text was updated successfully, but these errors were encountered: