Skip to content

Commit 1c75878

Browse files
unaoSalakar
authored andcommitted
adds option to specify shape of callable function params and result, defaulting to any (#1853)
1 parent 92a115a commit 1c75878

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/index.d.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -2188,17 +2188,18 @@ declare module 'react-native-firebase' {
21882188
/**
21892189
* An HttpsCallableResult wraps a single result from a function call.
21902190
*/
2191-
interface HttpsCallableResult {
2192-
readonly data: any;
2191+
interface HttpsCallableResult<R = any> {
2192+
readonly data: R;
21932193
}
21942194

21952195
/**
21962196
* An HttpsCallable is a reference to a "callable" http trigger in
21972197
* Google Cloud Functions.
21982198
*/
2199-
interface HttpsCallable {
2200-
(data?: any): Promise<HttpsCallableResult>;
2201-
}
2199+
type HttpsCallable<Params, Result> =
2200+
Params extends void ?
2201+
() => Promise<HttpsCallableResult<Result>> :
2202+
(data: Params) => Promise<HttpsCallableResult<Result>>
22022203

22032204
/**
22042205
* `FirebaseFunctions` represents a Functions app, and is the entry point for
@@ -2212,7 +2213,7 @@ declare module 'react-native-firebase' {
22122213
* @param name The name of the https callable function.
22132214
* @return The `HttpsCallable` instance.
22142215
*/
2215-
httpsCallable(name: string): HttpsCallable;
2216+
httpsCallable<Params = any, Result = any>(name: string): HttpsCallable<Params, Result>;
22162217

22172218
/**
22182219
* Changes this instance to point to a Cloud Functions emulator running

0 commit comments

Comments
 (0)