Nope
node: 12.14.0
firebase-functions: 3.3.0
firebase-tools: 7.7.0
firebase-admin: 7.11.0
functions.https.onRequest(async (request, response) => {
console.log(request.query) // Property query does not exist on type Request
return response.send("ok")
})
...
I expect the type query to actually exist.
functions.https.onRequest(async (request, response) => {
console.log(request.query) // Property query does not exist on type Request
return response.send("ok")
})
This has changed since I updated firebase-functions from 3.0.1 to 3.3.0. Downgrading doesn't seem to work. It is a typing issue with typescript.
Since I run TypeScript before deploying, no
I suspect this is the same root cause as #587. Something happened between 3.0.1 and 3.3.0 with one of the types dependencies I'm guessing.
Same here after upgrading from 3.3.0 to 3.6.0. In my case, it complains about such code:
functions.https.onRequest((_req, resp) => resp.end())
Property 'end' does not exist on type 'Response
'
Same for me after upgrading from 3.3.0 to 3.6.0
@ludovicfourrage what version of express are you on? If it is not version 4.17.3 or above, can you install that and see if that fixes the issue?
yarn upgrade fix my problem after upgrading firebase-functions from 3.3.0 to 3.6.0, and got these errors messages:
$ tsc
node_modules/@types/express/index.d.ts:98:128 - error TS2694: Namespace '"/home/user/Documents/project/functions/node_modules/@types/express-serve-static-core/index"' has no exported member 'Query'.
98 interface ErrorRequestHandler<P extends core.Params = core.ParamsDictionary, ResBody = any, ReqBody = any, ReqQuery = core.Query>
~~~~~
node_modules/@types/express/index.d.ts:99:17 - error TS2707: Generic type 'ErrorRequestHandler' requires between 0 and 3 type arguments.
99 extends core.ErrorRequestHandler<P, ResBody, ReqBody, ReqQuery> { }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/express/index.d.ts:108:116 - error TS2694: Namespace '"/home/user/Documents/project/functions/node_modules/@types/express-serve-static-core/index"' has no exported member 'Query'.
108 interface Request<P extends core.Params = core.ParamsDictionary, ResBody = any, ReqBody = any, ReqQuery = core.Query> extends core.Request<P, ResBody, ReqBody, ReqQuery> { }
~~~~~
node_modules/@types/express/index.d.ts:108:131 - error TS2707: Generic type 'Request<P, ResBody, ReqBody>' requires between 0 and 3 type arguments.
108 interface Request<P extends core.Params = core.ParamsDictionary, ResBody = any, ReqBody = any, ReqQuery = core.Query> extends core.Request<P, ResBody, ReqBody, ReqQuery> { }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/express/index.d.ts:109:123 - error TS2694: Namespace '"/home/user/Documents/project/functions/node_modules/@types/express-serve-static-core/index"' has no exported member 'Query'.
109 interface RequestHandler<P extends core.Params = core.ParamsDictionary, ResBody = any, ReqBody = any, ReqQuery = core.Query> extends core.RequestHandler<P, ResBody, ReqBody, ReqQuery> { }
~~~~~
node_modules/@types/express/index.d.ts:109:138 - error TS2707: Generic type 'RequestHandler<P, ResBody, ReqBody>' requires between 0 and 3 type arguments.
109 interface RequestHandler<P extends core.Params = core.ParamsDictionary, ResBody = any, ReqBody = any, ReqQuery = core.Query> extends core.RequestHandler<P, ResBody, ReqBody, ReqQuery> { }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 6 errors.
error Command failed with exit code 2.
Any solution?
@joaoeudes7 could you try running npm i typescript@latest --save-dev to get the latest version of Typescript and let me know if that helps?
updating @types/express-serve-static-core helped resolve it for me.
npm install @types/express-serve-static-core
I'm having the same thing again. Installing @types/express-serve-static-core did not work for me.
I see the following: when I go to the "Type Definitions" of https.Request, it takes me to the file
functions/node_modules/firebase-functions/lib/providers/https.d.ts
There, on line 6, the following code is found:
export interface Request extends express.Request {
rawBody: Buffer;
}
It is trying to extend from express.Request, but when hovering over express.Request, Visual Studio Code is not recognizing express.Request as a class (_No type definitions found for Request_). It is extending from nothing as far as VSC knows.
Alright, installing @types/express-serve-static-core actually did take away the initial express.Request error, but it brought in new definitions for request.query, which is why my code won't compile anymore. these new definitions are based on qs, according the the docs of Express an "extended parser". It is not the default behaviour of Firebase to use an extended parser, but the typing assumes it is using this parser.
Somehow the Firebase's variant of @types/express-serve-static-core is not shipped with the package.
Next findings: I had express installed next to firebase-functions. Deleting this from my package.json resulted in a correct install of firebase-functions, including @types/express-serve-static-core. The request.query typing problem persists though.
I'm also seeing the Generic type 'Request<P>' requires between 0 and 1 type arguments" and Namespace '"myproject/node_modules/@types/express-serve-static-core/index"' has no exported member 'Query' errors after upgrading to [email protected] (from 3.3.0).
Adding @types/[email protected] and @types/[email protected] did not help in my case. Just created more errors.
See https://github.com/firebase/firebase-functions/issues/681 - the fix is to upgrade firebase-admin to 8.12.1, or add skipLibCheck: true to tsconfig.json. Wish I'd known this this morning!
I was facing this issue on 9.4.1, however I deleted the yarn.lock and re-installed the dependencies and that fixed it
Most helpful comment
Same here after upgrading from
3.3.0to3.6.0. In my case, it complains about such code: