- Notifications
You must be signed in to change notification settings - Fork 219
Open
Labels
Description
Related issues
None found for this typing gap with defineJsonSecret and secrets arrays.
[REQUIRED] Version info
node: node --version (v24.11.1)
firebase-functions: from package.json (7.0.0)
firebase-tools: firebase --version (14.26.0)
firebase-admin: from package.json (13.6.0)
[REQUIRED] Test case
import { defineJsonSecret, onRequest } from 'firebase-functions/https'; interface Config { foo: string; } const jsonSecret = defineJsonSecret<Config>('JSON_SECRET'); export const test = onRequest( { secrets: [jsonSecret] }, // TS error here (_req, res) => { res.json({ foo: jsonSecret.value().foo }); } );[REQUIRED] Steps to reproduce
- Install firebase-functions v7.0.0.
- Define a JSON secret with
defineJsonSecret. - Pass the resulting
JsonSecretParaminto thesecretsarray of a function. - Compile with TypeScript.
[REQUIRED] Expected behavior
TypeScript accepts JsonSecretParam in secrets (just like SecretParam or a string name), since JSON secrets are supported at runtime.
[REQUIRED] Actual behavior
TypeScript error:
Type 'JsonSecretParam<Config>' is not assignable to type 'string | SecretParam'. Type 'JsonSecretParam<Config>' is not assignable to type 'SecretParam'. The types returned by 'value()' are incompatible between these types. Type 'Config' is not assignable to type 'string'. SDK typings show secrets?: (string | SecretParam)[]; across options. JsonSecretParam is defined in params/types, but not accepted by secrets. Runtime converters also only check instanceof SecretParam.
Were you able to successfully deploy your functions?
This is a compile time issue, I did not attempt to deploy.
mariano-filipe and sambecker