-
Notifications
You must be signed in to change notification settings - Fork 221
Open
Description
In the types definition here, the topic can only be a string. Also, here, there is no check if to see if the topic is a parameter and retrieve the value of it unlike in other function types.
Related issues
None that I could find.
[REQUIRED] Version info
node: v20.10.0
firebase-functions: v7.0.1
firebase-tools: v15.1.0
firebase-admin:
[REQUIRED] Test case
import {defineString} from "firebase-functions/params";
import {onMessagePublished} from "firebase-functions/v2/pubsub";
const topicName = defineString("some-topic");
export const myMessageConsumer = onMessagePublished(
{
topic: topicName
},
async (message) => {
console.log(message);
}
);
firebase deploy --only functions:myMessageConsumer
[REQUIRED] Steps to reproduce
See test case above
[REQUIRED] Expected behavior
During deployment, the function should deploy successfully and the parameter used and configured at deploy-time should parse and configure the topic to receive messages from.
[REQUIRED] Actual behavior
Function fails to deploy
Were you able to successfully deploy your functions?
No
src/functions/test.ts:6:34 - error TS2769: No overload matches this call.
Overload 1 of 2, '(topic: string, handler: (event: CloudEvent<MessagePublishedData<any>>) => any): CloudFunction<CloudEvent<MessagePublishedData<any>>>', gave the following error.
Argument of type '{ topic: StringParam; }' is not assignable to parameter of type 'string'.
Overload 2 of 2, '(options: PubSubOptions, handler: (event: CloudEvent<MessagePublishedData<any>>) => any): CloudFunction<CloudEvent<MessagePublishedData<any>>>', gave the following error.
Type 'StringParam' is not assignable to type 'string'.
6 export const myMessageConsumer = onMessagePublished(
~~~~~~~~~~~~~~~~~~~
7 {
~~~~~
...
12 }
~~~~~
13 );
~
node_modules/firebase-functions/lib/v2/providers/pubsub.d.ts:86:5
86 topic: string;
~~~~~
The expected type comes from property 'topic' which is declared here on type 'PubSubOptions'
Metadata
Metadata
Assignees
Labels
No labels