-
Notifications
You must be signed in to change notification settings - Fork 58
Typescript error with V2 wrap
: Type '{ data: WhatEverType; }' is missing the following properties from type 'CallableRequest<any>': rawRequest, acceptsStreaming
#257
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
Comments
Hi @sceee, Thanks for reporting this issue! We’ve received it and are reviewing it. We’ll provide updates as soon as possible. |
Have you tried using the |
Hi @CorieW , No, I used This sample is referenced on the Readme of this repo: If these samples are outdated and instead However, even if I try it with the const response = await wrapV2(myFunctions.fnsmyV2Function)({ data: { whatever: "mydatais" }) ...I still get the same error:
|
The function returned by
So we have to pass that entire request payload:
Something like this works, though there should be a better way to handle AppCheck and Auth than manually mocking:
|
Thanks @sbuys for your sample. Of course, you can "make Typescript happy" using something like your mentioned But during runtime, So instead of having to just fake the types to make TS happy, I would prefer if The need that users of this library would have to do this does not seem logical to me. As I wrote in the description of this issue, I would prefer if |
Oh I agree with you - in its current form, For the testing library to be useful, it should really help with the boilerplate required to build up Testing has always felt like an afterthought with firebase though. The tooling / documentation has always been weak. Right now we find it easier to just run everything "offline" and call our functions directly, mocking all firebase calls. This requires a good amount of work to setup initially but it means we aren't reliant on testing tools from firebase, which historically have not been a priority. Also depending on the emulators is risky business. |
@CorieW just as reminder as I feel something is wrong with the "Needs author feedback" label: |
@sceee Yeah, you're right, it should be removed automatically. Though, not to worry, I'm aware you've given feedback. I'm just a bit tied up with other work at the moment, but I'll see about investigating this issue as soon as possible. Thanks for your patience! |
Following up on the now closed #163 , there is still a type issue with
wrap
when trying to test v2 functions.For example, if we just want to call the function:
...this creates the following Typescript error:
It is indeed a usecase to set
rawRequest
sometimes in the wrapped request, e.g. if you want to fake some parameters of the request.So I think that the wrapped function parameter should be typed
Partial<CallableRequest<any>>
.Ideally, it should infer the request object
any
from the originalCallableFunction
definition so it is typedPartial<CallableRequest<WhatEverTypeMyParameterTypeIs>>
.Even better, the then optional
rawRequest
property should also be aPartial<Request>
so we can only provide the values we need for a test.The text was updated successfully, but these errors were encountered: