Skip to content

CallableOptions doesn't accept BooleanParam which is accepted by HttpsOptions #1554

@eli1stark

Description

@eli1stark

Related issues

[REQUIRED] Version Info

node: v20.7.0

firebase-functions: v4.5.0

firebase-admin: v11.11.1

[REQUIRED] Test case

Provided below.

[REQUIRED] Steps to reproduce

When env variable used as shown in Google Docs it doesn't compile with CallableOptions, however the same param is used without issues with HttpsOptions. CallableOptions extends HttpsOptions, so it should have the same behavior as HttpsOptions.

my_function.ts

import {defineBoolean} from "firebase-functions/params";
import {onCall} from "firebase-functions/v2/https";

const enforceAppCheck = defineBoolean("ENFORCE_APP_CHECK");

export const myFunction = onCall({
  enforceAppCheck: enforceAppCheck,
}, async (request) => {

});

.env

ENFORCE_APP_CHECK=false

[REQUIRED] Expected behavior

env variable should be assignable without compile errors.

[REQUIRED] Actual behavior

Type 'BooleanParam' is not assignable to type 'boolean | undefined'.ts(2322)
https.d.ts(111, 5): The expected type comes from property 'enforceAppCheck' which is declared here on type 'CallableOptions'

Were you able to successfully deploy your functions?

Function doesn't deploy due to compile issues.

FIX

To fix the issue we need to update the code below:

export interface CallableOptions extends HttpsOptions {
  enforceAppCheck?: boolean;
  consumeAppCheckToken?: boolean;
}

to this code:

export interface CallableOptions extends HttpsOptions {
  enforceAppCheck?: boolean | Expression<boolean>;
  consumeAppCheckToken?: boolean | Expression<boolean>;
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions