Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type WrappedV2Function<T extends CloudEvent<unknown>> = (
) => any | Promise<any>;

export type WrappedV2CallableFunction<T> = (
data: CallableRequest
data: DeepPartial<CallableRequest>
Comment on lines 37 to +38
Copy link
Preview

Copilot AI May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using DeepPartial<CallableRequest> may allow invalid or incomplete payloads at runtime. Consider documenting which fields remain required or introduce a narrower helper type for testing vs. production usage.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this either, see for example:

import { wrapV2 } from 'firebase-functions-test/lib/v2';
import { onCall } from 'firebase-functions/v2/https';

interface HelloResult { greeting: string; }

const stub = onCall<{}, HelloResult>((req) => {

  console.log('HTTP method:', req.rawRequest.method);

  return { greeting: `Hello!` };
});

// 2) Wrap it
const invoke = wrapV2(stub);

// 3) This should be a compile‐time error, but compiles fine under the PR:
invoke({
  data: {},   // TS should complain: “Property 'rawRequest' is missing” etc
});

The change makes this fine according to the typescript compilation, but at runtime of the test we'll get an error.

I feel like the library should build some defaults?

like here in v1 for event context:

https://github.com/firebase/firebase-functions-test/blob/master/src/v1.ts#L141

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great call. Instead of loosening the type, maybe we just need to provide sensible default so that user doesn't have to manually construct and pass callable context when invoking their v2 callable fn.

) => T | Promise<T>;

function isCallableV2Function<T extends CloudEvent<unknown>>(
Expand Down