Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SecretParam TS type is not exported #2439

Closed
gregfenton opened this issue Feb 1, 2024 · 2 comments
Closed

SecretParam TS type is not exported #2439

gregfenton opened this issue Feb 1, 2024 · 2 comments

Comments

@gregfenton
Copy link

gregfenton commented Feb 1, 2024

Describe your environment

  • Operating System version: Mac Sonoma 14.3
  • Firebase SDK version: v12.0.0
  • Firebase Product: Admin SDK for NodeJS
  • Node.js version: v18.17.1
  • NPM version: 9.8.1
  • VSCode version: 1.85.2
  • ESLint version: 8.56.0
  • @typescript-eslint/eslint-plugin version: 6.20.0

Describe the problem

Using VSCode with ESLint & TypeScript enabled, I am trying to write a function that takes the results of defineSecret() and does some processing on it to reduce code duplication across my project. The issue is that the datatype returned, SecretParam, is not exported.

When trying:

import {SecretParam} from 'firebase-functions/params';

VSCode reports:

Module '"firebase-functions/params"' declares 'SecretParam' locally, but it is not exported.ts(2459)
index.d.ts(5, 67): 'SecretParam' is declared here.

TSC errors out with:

error TS2459: Module '"firebase-functions/params"' declares 'SecretParam' locally, but it is not exported.

Relevant Code:

The code below is throwing ESLint errors and fails to compile with tsc:

import {SecretParam} from 'firebase-functions/params';

export const safeGetConfigJsonVal = (secretKey: SecretParam): Record<string, any> => {
  if (!secretKey.value()) {
    throw new Error('secretKey.value() is null/undefined');
  }

  let myConfig;
  try {
    myConfig = JSON.parse(secretKey.value());
    return myConfig;
  } catch (ex) {
    throw new Error(
      `secretKey is not a valid JSON string: ${secretKey.value()}`
    );
  }
};

Workaround:

Put // @ts-ignore on the line immediately before the import line

@google-oss-bot
Copy link

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@lahirumaramba
Copy link
Member

Looks like the issue may have been addressed in the functions SDK https://github.com/firebase/firebase-functions/blob/9c818713db511895a33378859ab1b9f2eef99179/src/params/types.ts#L429

If you are still experiencing this issue please open a new ticket on the https://github.com/firebase/firebase-functions/tree/master repo.

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

No branches or pull requests

3 participants