Skip to content

Unable to use result of defineString in runWith config #5347

Closed

Description

@RYFN

[REQUIRED] Environment info

firebase-tools: 11.18.0

Platform: macOS

[REQUIRED] Test case

Params docs https://firebase.google.com/docs/functions/config-env#params state

// To use configured parameters inside the config for a function, provide them
// directly. To use them at runtime, call .value() on them.

However, attempting to use this in a typescript deployment of a function;

import { defineString } from 'firebase-functions/params';
...
const vpcConnector = defineString('MY_VPC');

export const someFunction = functions
    .region('europe-west2')
    .runWith({
        vpcConnector: vpcConnector,
        vpcConnectorEgressSettings: 'ALL_TRAFFIC'
    })
    .https.onCall(async (data, context) => {
          ...

Leads to TS error Type 'StringParam' is not assignable to type 'string | ResetValue | undefined'. Type 'Param<string>' is not assignable to type 'ResetValue'.

I can vpcConnector: vpcConnector.value() but from the docs, this seems like an incorrect approach?

Screenshot 2022-12-19 at 12 17 59

[REQUIRED] Steps to reproduce

See example above.

[REQUIRED] Expected behavior

Use variables created from defineString in runtime config in TS function

[REQUIRED] Actual behavior

Types won't allow return value of defineString to be used in runtime config.

Activity

  1. google-oss-bot commented on Dec 19, 2022

    @google-oss-bot
    Collaborator

    This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

  2. Berlioz commented on Dec 20, 2022

    @Berlioz
    Contributor

    Seems like we forgot to update the type definition of VpcConnector in the options structs. firebase/firebase-functions#1329 should fix it.

  3. RYFN commented on Feb 13, 2023

    @RYFN
    Author

    The above fix is working great for VpcConnector! Thank you.

    An extension to this, when using defineString in region, workaround of casting as any works, but is undesirable. Using v4.2.1

    Screenshot 2023-02-13 at 15 43 56

    Would you like me to raise this as a separate issue?

  4. joehan commented on Feb 14, 2023

    @joehan
    Member

    @RYFN Yep, please raise a separate issue for that. I'm gonna close this one since it appears to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions