Skip to content

Typescript error with V2 wrap: Type '{ data: WhatEverType; }' is missing the following properties from type 'CallableRequest<any>': rawRequest, acceptsStreaming #257

Description

@sceee

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:

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<any>': 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<CallableRequest<any>>.

Ideally, it should infer the request object any from the original CallableFunction definition so it is typed Partial<CallableRequest<WhatEverTypeMyParameterTypeIs>>.

Even better, the then optional rawRequest property should also be a Partial<Request> so we can only provide the values we need for a test.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions