Skip to content

Commit 867968b

Browse files
fix: typing
1 parent 0a0f8dd commit 867968b

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

packages/functions/__tests__/functions.test.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ describe('Cloud Functions', function () {
117117
});
118118

119119
it('`FunctionsModule` type is properly exposed to end user', function () {
120-
// @ts-ignore - firebase.app() returns a wider type at runtime
121-
const functionsInstance: FunctionsModule = firebase.app().functions();
120+
const functionsInstance: FunctionsModule = (
121+
firebase.app() as unknown as FirebaseApp
122+
).functions();
122123
expect(functionsInstance).toBeDefined();
123124
expect(functionsInstance.httpsCallable).toBeDefined();
124125
expect(functionsInstance.httpsCallableFromUrl).toBeDefined();
@@ -127,14 +128,12 @@ describe('Cloud Functions', function () {
127128
});
128129

129130
it('`Functions` type is properly exposed to end user', function () {
130-
// @ts-ignore - firebase.app() returns a wider type at runtime
131-
const functionsInstance: Functions = firebase.app().functions();
131+
const functionsInstance: Functions = (firebase.app() as unknown as FirebaseApp).functions();
132132
expect(functionsInstance).toBeDefined();
133133
});
134134

135135
it('`FirebaseApp` type is properly exposed to end user', function () {
136-
// @ts-ignore - This type augments the base FirebaseApp type
137-
const app: FirebaseApp = firebase.app();
136+
const app = firebase.app() as unknown as FirebaseApp;
138137
expect(app).toBeDefined();
139138
expect(app.functions).toBeDefined();
140139
});
@@ -167,9 +166,7 @@ describe('Cloud Functions', function () {
167166

168167
describe('Cloud Functions', function () {
169168
it('useFunctionsEmulator()', function () {
170-
const app = getApp();
171-
// @ts-ignore - app has functions() at runtime
172-
const functions = app.functions();
169+
const functions = (getApp() as unknown as FirebaseApp).functions();
173170
functionsRefV9Deprecation(
174171
() => connectFunctionsEmulator(functions, 'localhost', 8080),
175172
() => functions.useEmulator('localhost', 8080),
@@ -178,9 +175,7 @@ describe('Cloud Functions', function () {
178175
});
179176

180177
it('httpsCallable()', function () {
181-
const app = getApp();
182-
// @ts-ignore - app has functions() at runtime
183-
const functions = app.functions();
178+
const functions = (getApp() as unknown as FirebaseApp).functions();
184179
functionsRefV9Deprecation(
185180
() => httpsCallable(functions, 'example'),
186181
() => functions.httpsCallable('example'),
@@ -189,9 +184,7 @@ describe('Cloud Functions', function () {
189184
});
190185

191186
it('httpsCallableFromUrl()', function () {
192-
const app = getApp();
193-
// @ts-ignore - app has functions() at runtime
194-
const functions = app.functions();
187+
const functions = (getApp() as unknown as FirebaseApp).functions();
195188
functionsRefV9Deprecation(
196189
() => httpsCallableFromUrl(functions, 'https://example.com/example'),
197190
() => functions.httpsCallableFromUrl('https://example.com/example'),

packages/functions/lib/modular.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ import type {
3232
*/
3333
export function getFunctions(app?: FirebaseApp, regionOrCustomDomain?: string): Functions {
3434
if (app) {
35-
return getApp(app.name).functions(regionOrCustomDomain) as Functions;
35+
return (getApp(app.name) as unknown as FirebaseApp).functions(regionOrCustomDomain);
3636
}
3737

38-
return getApp().functions(regionOrCustomDomain) as Functions;
38+
return (getApp() as unknown as FirebaseApp).functions(regionOrCustomDomain);
3939
}
4040

4141
/**

0 commit comments

Comments
 (0)