Description
Version info
firebase-functions-test: 2.3.0
firebase-functions: 3.22.0
firebase-admin: 9.1.1
Test case
Live code:
import * as functions from "firebase-functions/v2";
export const myv2function = functions.https.onCall(
{ minInstances: 1 },
async ({data, auth }) => {
...
}
);
Note the above syntax differences from v1 onCall functions. There is no longer a pair of (data, context)
parameters, only a single functions.https.CallableRequest<any>
parameter. Additionally, the function options (e.g. minInstances
) is a parameter instead of a sub-function of the functions
class.
Test code:
import fftest from "firebase-functions-test";
const fft = fftest();
describe("test", () => {
let functions;
before(() => {
functions = require("./myv2function.f");
});
it("My first test", async () => {
const wrappedFunction = fft.wrap(functions.myv2function);
let data = {};
let result = await wrappedFunction({ data, auth: { uid: "uid" } });
});
});
Steps to reproduce
Run the above sample with a //@ts-ignore
above the await wrappedFunction(...)
line. It works fine and seems like the wrapping for the new v2 functions works well. However, when removing the //@ts-ignore
line, I get a type error. If I try to run the test code with the old v1 syntax (data, context)
it does not work either.
Expected behavior
No type error when running the above code snippet, as the code is correct. v2 function overload signature needs to be added.
Actual behavior
Receive type error
Argument of type '{ data: {}; auth: { uid: string; }; }' is not assignable to parameter of type 'ContextOptions | undefined'.
Object literal may only specify known properties, and 'data' does not exist in type 'ContextOptions'.ts(2345)