Skip to content

Commit 8775696

Browse files
authored
Improve typing (#185)
1 parent 8e518b7 commit 8775696

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/features.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as database from './providers/database';
55
import * as firestore from './providers/firestore';
66
import * as pubsub from './providers/pubsub';
77
import * as storage from './providers/storage';
8+
import { FirebaseFunctionsTest } from './lifecycle';
89

910
export interface LazyFeatures {
1011
mockConfig: typeof mockConfig;
@@ -31,5 +32,5 @@ export const features: LazyFeatures = {
3132
};
3233

3334
export interface FeaturesList extends LazyFeatures {
34-
cleanup;
35+
cleanup: InstanceType<typeof FirebaseFunctionsTest>['cleanup'];
3536
}

src/index.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,19 @@ import { AppOptions } from 'firebase-admin';
2424
import { merge } from 'lodash';
2525

2626
import { FirebaseFunctionsTest } from './lifecycle';
27-
import { features as lazyFeatures, FeaturesList } from './features';
27+
import { FeaturesList } from './features';
2828

29-
export = (firebaseConfig?: AppOptions, pathToServiceAccountKey?: string) => {
29+
export = (
30+
firebaseConfig?: AppOptions,
31+
pathToServiceAccountKey?: string
32+
): FeaturesList => {
3033
const test = new FirebaseFunctionsTest();
3134
test.init(firebaseConfig, pathToServiceAccountKey);
3235
// Ensure other files get loaded after init function, since they load `firebase-functions`
3336
// which will issue warning if process.env.FIREBASE_CONFIG is not yet set.
34-
let features = require('./features').features as typeof lazyFeatures;
37+
let features = require('./features').features;
3538
features = merge({}, features, {
3639
cleanup: () => test.cleanup(),
3740
});
38-
return features as FeaturesList;
41+
return features;
3942
};

0 commit comments

Comments
 (0)