firebase / firebase/firebase-functions-test
Typescript error with V2 `wrap`: Type '{ data: WhatEverType; }' is missing the following properties from type 'CallableRequest<any>': rawRequest, acceptsStreaming
- Dominant language
- TypeScript
- Stars
- 248
- Forks
- 63
- PR merge metrics
- No merged PRs in 30d
Description
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:
```typescript
await wrap(fnsmyV2Function)({ data: { whatever: "mydatais" } })
```
...this creates the following Typescript error:
```
Typescript error with V2 `wrap` Type '{ data: WhatEverTypeMyParameterTypeIs; }' is missing the following properties from type 'CallableRequest': rawRequest, acceptsStreaming
```
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>`.
Ideally, it should infer the request object `any` from the original `CallableFunction` definition so it is typed `Partial>`.
Even better, the then optional `rawRequest` property should also be a `Partial` so we can only provide the values we need for a test.
Contributor guide
Assessment
This issue has not been assessed yet.