Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions spec/v1/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ import { config } from "../../src/v1/config";

describe("config()", () => {
it("throws an error with migration guidance", () => {
expect(config).to.throw(
expect(() => {
// @ts-expect-error - config is deprecated and typed as never to cause a build error
config();
}).to.throw(
Error,
"functions.config() has been removed in firebase-functions v7. " +
"Migrate to environment parameters using the params module. " +
"Migration guide: https://firebase.google.com/docs/functions/config-env#migrate-config"
);
});
});
});
4 changes: 2 additions & 2 deletions src/v1/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export { firebaseConfig } from "../common/config";
* Migrate to environment parameters using the `params` module immediately.
* Migration guide: https://firebase.google.com/docs/functions/config-env#migrate-config
*/
export function config(): Record<string, any> {
export const config: never = (() => {
throw new Error(
"functions.config() has been removed in firebase-functions v7. " +
"Migrate to environment parameters using the params module. " +
"Migration guide: https://firebase.google.com/docs/functions/config-env#migrate-config"
);
}
}) as unknown as never;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does adding in the as unknown do? I tried removing it in the TS playground and it doesn't seem to change anything

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iiuc as unknown basically erases types before and I think I needed to do it to ultimately cast this type as never to prevent tsc from complaining. let me double check to confirm!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed that this isn't necessary. Great catch!

Loading