You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having trouble setting the region property of my Gen 2 Firebase Functions using TypeScript and a parameterized variable due to type mismatch issues. Here's a sample of my .env file:
LOCATION="australia-southeast1"
I have attempted to define the region both globally and at the function level.
1. Defining region globally using setGlobalOptions
I would prefer to define the region globally using setGlobalOptions.
The global region property on setGlobalOptions has a type of GlobalOptions.region?: string | Expression<string> | ResetValue | undefined. This is slightly different from the function level type HttpsOptions.region?: string | string[] | Expression<string> | ResetValue | undefined as the global level only allows for a singular string and no string[].
No matter what I do at the global level, it fails. All three of these attempts give a deployment error Error: Illegal type coercion of param LOCATION to type string[]:
Therefore, I am unsure how to define region on setGlobalOptions using a parameterized variable.
2. Defining region at the function level
When I tried defining region at the function level, the IDE showed region as HttpsOptions.region?: string | string[] | Expression<string> | ResetValue | undefined.
I thought defineString() would work as it returns a string. Although there were no errors in the IDE, during deployment I received this error Error: Illegal type coercion of param LOCATION to type string[].
Type 'ListParam' is not assignable to type 'string | string[] | Expression<string> | ResetValue | undefined'.
Type 'ListParam' is not assignable to type 'Expression<string>'.
The types returned by 'value()' are incompatible between these types.
Type 'string[]' is not assignable to type 'string'.ts(2322)
The following works, but it is confusing because region should accept a string, so why do I need to use defineList() and further assert it with defineList("LOCATION") as unknown as string[]?
Overall there seems to be a lot of problems with the typing for region both at the function and global level.
I managed to get the function level working with an assertion, but I would still prefer to use region on setGlobalOptions with a parameterized variable.
Any help to resolve this issue would be greatly appreciated!
Environment:
Node.js: 16.16.0
firebase-functions: 4.4.1
firebase-tools: 12.4.4
firebase-admin: 11.10.1
The text was updated successfully, but these errors were encountered:
Issue Description:
I am having trouble setting the
region
property of my Gen 2 Firebase Functions using TypeScript and a parameterized variable due to type mismatch issues. Here's a sample of my.env
file:I have attempted to define the
region
both globally and at the function level.1. Defining region globally using
setGlobalOptions
I would prefer to define the
region
globally usingsetGlobalOptions
.The global
region
property onsetGlobalOptions
has a type ofGlobalOptions.region?: string | Expression<string> | ResetValue | undefined
. This is slightly different from the function level typeHttpsOptions.region?: string | string[] | Expression<string> | ResetValue | undefined
as the global level only allows for a singularstring
and nostring[]
.No matter what I do at the global level, it fails. All three of these attempts give a deployment error
Error: Illegal type coercion of param LOCATION to type string[]
:Therefore, I am unsure how to define
region
onsetGlobalOptions
using a parameterized variable.2. Defining region at the function level
When I tried defining
region
at the function level, the IDE showedregion
asHttpsOptions.region?: string | string[] | Expression<string> | ResetValue | undefined
.I thought
defineString()
would work as it returns astring
. Although there were no errors in the IDE, during deployment I received this errorError: Illegal type coercion of param LOCATION to type string[]
.Next, I tried to define the
region
usingdefineList()
, but that produced a type error in the IDE:Here is the IDE error:
The following works, but it is confusing because
region
should accept astring
, so why do I need to usedefineList()
and further assert it withdefineList("LOCATION") as unknown as string[]
?Overall there seems to be a lot of problems with the typing for
region
both at the function and global level.I managed to get the function level working with an assertion, but I would still prefer to use
region
onsetGlobalOptions
with a parameterized variable.Any help to resolve this issue would be greatly appreciated!
Environment:
The text was updated successfully, but these errors were encountered: