Description
[REQUIRED] Environment info
firebase-tools: 11.22.0
Platform: macOS
[REQUIRED] Test case
const region = defineString('REGION');
export const onCreate = functions
//results in TS error, see attached image
.region(region)
.firestore.document('document/{docId}')
.onCreate(async (snapshot, context)
[REQUIRED] Steps to reproduce
Per test case
[REQUIRED] Expected behavior
Should be able to use output of defineString to configure function region
[REQUIRED] Actual behavior
Need to cast result of defineString with as any
to allow typescript build. Function works as expected when deployed with
const region = defineString('REGION');
export const onCreate = functions
.region(region as any)
.firestore.document('document/{docId}')
.onCreate(async (snapshot, context)
Follow up to #5347, resolved by https://github.com/firebase/firebase-functions/pull/1329/files suspect adding Expression<string> |
to region config would fix this?
(further to this, what's best practice when using defineString in globally defined things in functions? e.g. using the following results in a deployment warning, but not using .value()
causes an error)
const redisUsername = defineString('REDIS_USERNAME')
//username expects a string
const redisOptions: RedisClientOptions = {
username: redisUsername.value()
};
...
export const onCreate = functions
.region(region as any)
.firestore.document('document/{docId}')
.onCreate(async (snapshot, context)
...