From 156a5576062b86c01b77aa19a38cd2437e8f598b Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 17:37:29 -0700 Subject: [PATCH 01/19] chore: enable TypeScript libcheck & remove "dom" lib "dom" conflicts with @types/react-native --- tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 75cfd6e7cb..998e899c88 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,10 +14,10 @@ "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "moduleResolution": "node", - "skipLibCheck": true, + "skipLibCheck": false, "experimentalDecorators": true, "emitDecoratorMetadata": true, - "lib": ["es2015", "es2016", "esnext", "dom"] + "lib": ["es2015", "es2016", "esnext"] }, "exclude": ["node_modules", "**/*.spec.ts"] } From 4deded3b4cf69875fbefaf6ea4fbd7c7e7b62747 Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 22:47:11 -0700 Subject: [PATCH 02/19] chore: add react types (referenced by admob types) --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 16016c924c..123a5cf153 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "@babel/preset-env": "7.9.5", "@babel/preset-flow": "7.9.0", "@types/jest": "^25.2.1", + "@types/react": "^16.9.49", "@types/react-native": "^0.62.0", "@typescript-eslint/eslint-plugin": "^2.18.0", "@typescript-eslint/parser": "^2.18.0", From e1eae60c4689f2554e22dd78a3a0ffb161b51489 Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 17:41:28 -0700 Subject: [PATCH 03/19] refactor(types, app): move "app" exports to top-level exports, rather than module declarations with namespace extensions --- packages/app/lib/index.d.ts | 48 ++++++++++++------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/packages/app/lib/index.d.ts b/packages/app/lib/index.d.ts index 93320d9621..ee81e45e12 100644 --- a/packages/app/lib/index.d.ts +++ b/packages/app/lib/index.d.ts @@ -148,6 +148,8 @@ export namespace ReactNativeFirebase { * Make this app unusable and free up resources. */ delete(): Promise; + + utils(): Utils.Module; } export interface Module { @@ -189,6 +191,13 @@ export namespace ReactNativeFirebase { * The current React Native Firebase version. */ readonly SDK_VERSION: string; + + /** + * Utils provides a collection of utilities to aid in using Firebase + * and related services inside React Native, e.g. Test Lab helpers + * and Google Play Services version helpers. + */ + utils: typeof utils; } /** @@ -536,37 +545,10 @@ export namespace Utils { } } -declare module '@react-native-firebase/app' { - /** - * Add Utils module as a named export for `app`. - */ - export const utils: ReactNativeFirebase.FirebaseModuleWithStatics; - - /** - * Default Firebase export. - */ - const module: {} & ReactNativeFirebase.Module; - export default module; -} +/** + * Add Utils module as a named export for `app`. + */ +export const utils: ReactNativeFirebase.FirebaseModuleWithStatics; -declare module '@react-native-firebase/app' { - /** - * Attach Utils namespace to `firebase.` and `FirebaseApp.`. - */ - namespace ReactNativeFirebase { - import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; - - interface Module { - /** - * Utils provides a collection of utilities to aid in using Firebase - * and related services inside React Native, e.g. Test Lab helpers - * and Google Play Services version helpers. - */ - utils: FirebaseModuleWithStatics; - } - - interface FirebaseApp { - utils(): Utils.Module; - } - } -} +declare const module: ReactNativeFirebase.Module; +export default module; From a921b56953fedbbdcb5c9bfc1b3d579adeb569ed Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 18:35:05 -0700 Subject: [PATCH 04/19] refactor(types): use top-level exports for module types, rather than declarations --- packages/admob/lib/index.d.ts | 54 +++++++++---------- packages/analytics/lib/index.d.ts | 28 +++++----- packages/auth/lib/index.d.ts | 26 ++++----- packages/crashlytics/lib/index.d.ts | 24 ++++----- packages/database/lib/index.d.ts | 28 +++++----- packages/dynamic-links/lib/index.d.ts | 28 +++++----- packages/firestore/lib/index.d.ts | 28 +++++----- packages/functions/lib/index.d.ts | 24 ++++----- packages/iid/lib/index.d.ts | 22 ++++---- packages/in-app-messaging/lib/index.d.ts | 24 ++++----- packages/messaging/lib/index.d.ts | 28 +++++----- packages/ml-natural-language/lib/index.d.ts | 24 ++++----- packages/ml-vision/lib/index.d.ts | 58 ++++++++++----------- packages/perf/lib/index.d.ts | 26 ++++----- packages/remote-config/lib/index.d.ts | 24 ++++----- packages/storage/lib/index.d.ts | 26 ++++----- scripts/_TEMPLATE_/lib/index.d.ts | 17 +++--- 17 files changed, 222 insertions(+), 267 deletions(-) diff --git a/packages/admob/lib/index.d.ts b/packages/admob/lib/index.d.ts index eba141c1e2..fdb97616d5 100644 --- a/packages/admob/lib/index.d.ts +++ b/packages/admob/lib/index.d.ts @@ -14,8 +14,8 @@ * limitations under the License. * */ - import { ReactNativeFirebase } from '@react-native-firebase/app'; +import * as React from 'react'; /** * Firebase Admob package for React Native. @@ -1180,35 +1180,29 @@ export namespace FirebaseAdMobTypes { } } -declare module '@react-native-firebase/admob' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import React from 'react'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; - import BannerAd = FirebaseAdMobTypes.BannerAd; - - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; - - export const AdsConsentDebugGeography: {} & FirebaseAdMobTypes.AdsConsentDebugGeography; - export const AdsConsentStatus: {} & FirebaseAdMobTypes.AdsConsentStatus; - export const MaxAdContentRating: {} & FirebaseAdMobTypes.MaxAdContentRating; - export const TestIds: {} & FirebaseAdMobTypes.TestIds; - export const AdEventType: {} & FirebaseAdMobTypes.AdEventType; - export const BannerAdSize: {} & FirebaseAdMobTypes.BannerAdSize; - export const RewardedAdEventType: {} & FirebaseAdMobTypes.RewardedAdEventType; - export const AdsConsent: {} & FirebaseAdMobTypes.AdsConsent; - export const InterstitialAd: typeof FirebaseAdMobTypes.InterstitialAd; - export const RewardedAd: typeof FirebaseAdMobTypes.RewardedAd; - export const BannerAd: React.SFC; - - const defaultExport: FirebaseModuleWithStaticsAndApp< - FirebaseAdMobTypes.Module, - FirebaseAdMobTypes.Statics - >; - export default defaultExport; -} +export const AdsConsentDebugGeography: FirebaseAdMobTypes.AdsConsentDebugGeography; +export const AdsConsentStatus: FirebaseAdMobTypes.AdsConsentStatus; +export const MaxAdContentRating: FirebaseAdMobTypes.MaxAdContentRating; +export const TestIds: FirebaseAdMobTypes.TestIds; +export const AdEventType: FirebaseAdMobTypes.AdEventType; +export const BannerAdSize: FirebaseAdMobTypes.BannerAdSize; +export const RewardedAdEventType: FirebaseAdMobTypes.RewardedAdEventType; +export const AdsConsent: FirebaseAdMobTypes.AdsConsent; +export const InterstitialAd: typeof FirebaseAdMobTypes.InterstitialAd; +export const RewardedAd: typeof FirebaseAdMobTypes.RewardedAd; +export const BannerAd: React.SFC; + +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp< + FirebaseAdMobTypes.Module, + FirebaseAdMobTypes.Statics +>; + +export const firebase: ReactNativeFirebase.Module & { + storage: typeof defaultExport; + app(name?: string): ReactNativeFirebase.FirebaseApp & { admob(): FirebaseAdMobTypes.Module }; +}; + +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/analytics/lib/index.d.ts b/packages/analytics/lib/index.d.ts index a0796b23b5..c6b7664a2a 100644 --- a/packages/analytics/lib/index.d.ts +++ b/packages/analytics/lib/index.d.ts @@ -1480,21 +1480,19 @@ export namespace FirebaseAnalyticsTypes { } } -declare module '@react-native-firebase/analytics' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; - - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; - - const defaultExport: FirebaseModuleWithStatics< - FirebaseAnalyticsTypes.Module, - FirebaseAnalyticsTypes.Statics - >; - export default defaultExport; -} +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStatics< + FirebaseAnalyticsTypes.Module, + FirebaseAnalyticsTypes.Statics +>; + +export const firebase: ReactNativeFirebase.Module & { + analytics: typeof defaultExport; + app( + name?: string, + ): ReactNativeFirebase.FirebaseApp & { analytics(): FirebaseAnalyticsTypes.Module }; +}; + +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/auth/lib/index.d.ts b/packages/auth/lib/index.d.ts index fc451a56fb..286111a020 100644 --- a/packages/auth/lib/index.d.ts +++ b/packages/auth/lib/index.d.ts @@ -1634,21 +1634,17 @@ export namespace FirebaseAuthTypes { type CallbackOrObserver any> = T | { next: T }; -declare module '@react-native-firebase/auth' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; - - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; - - const defaultExport: FirebaseModuleWithStaticsAndApp< - FirebaseAuthTypes.Module, - FirebaseAuthTypes.Statics - >; - export default defaultExport; -} +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp< + FirebaseAuthTypes.Module, + FirebaseAuthTypes.Statics +>; + +export const firebase: ReactNativeFirebase.Module & { + auth: typeof defaultExport; + app(name?: string): ReactNativeFirebase.FirebaseApp & { auth(): FirebaseAuthTypes.Module }; +}; + +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/crashlytics/lib/index.d.ts b/packages/crashlytics/lib/index.d.ts index f51861272f..ed1ef6e829 100644 --- a/packages/crashlytics/lib/index.d.ts +++ b/packages/crashlytics/lib/index.d.ts @@ -249,21 +249,19 @@ export namespace FirebaseCrashlyticsTypes { } } -declare module '@react-native-firebase/crashlytics' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStatics< + FirebaseCrashlyticsTypes.Module, + FirebaseCrashlyticsTypes.Statics +>; - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; +export const firebase: ReactNativeFirebase.Module & { + crashlytics: typeof defaultExport; + app( + name?: string, + ): ReactNativeFirebase.FirebaseApp & { crashlytics(): FirebaseCrashlyticsTypes.Module }; +}; - const defaultExport: FirebaseModuleWithStatics< - FirebaseCrashlyticsTypes.Module, - FirebaseCrashlyticsTypes.Statics - >; - export default defaultExport; -} +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/database/lib/index.d.ts b/packages/database/lib/index.d.ts index dcb2894823..8ae13aab40 100644 --- a/packages/database/lib/index.d.ts +++ b/packages/database/lib/index.d.ts @@ -1248,21 +1248,19 @@ export namespace FirebaseDatabaseTypes { } } -declare module '@react-native-firebase/database' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; - - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; - - const defaultExport: FirebaseModuleWithStaticsAndApp< - FirebaseDatabaseTypes.Module, - FirebaseDatabaseTypes.Statics - >; - export default defaultExport; -} +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp< + FirebaseDatabaseTypes.Module, + FirebaseDatabaseTypes.Statics +>; + +export const firebase: ReactNativeFirebase.Module & { + database: typeof defaultExport; + app( + name?: string, + ): ReactNativeFirebase.FirebaseApp & { database(): FirebaseDatabaseTypes.Module }; +}; + +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/dynamic-links/lib/index.d.ts b/packages/dynamic-links/lib/index.d.ts index c8f0c45713..a51e648fa3 100644 --- a/packages/dynamic-links/lib/index.d.ts +++ b/packages/dynamic-links/lib/index.d.ts @@ -566,21 +566,19 @@ export namespace FirebaseDynamicLinksTypes { } } -declare module '@react-native-firebase/dynamic-links' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; - - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; - - const defaultExport: FirebaseModuleWithStatics< - FirebaseDynamicLinksTypes.Module, - FirebaseDynamicLinksTypes.Statics - >; - export default defaultExport; -} +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStatics< + FirebaseDynamicLinksTypes.Module, + FirebaseDynamicLinksTypes.Statics +>; + +export const firebase: ReactNativeFirebase.Module & { + dynamicLinks: typeof defaultExport; + app( + name?: string, + ): ReactNativeFirebase.FirebaseApp & { dynamicLinks(): FirebaseDynamicLinksTypes.Module }; +}; + +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/firestore/lib/index.d.ts b/packages/firestore/lib/index.d.ts index 8ea648be9b..b557458647 100644 --- a/packages/firestore/lib/index.d.ts +++ b/packages/firestore/lib/index.d.ts @@ -2023,21 +2023,19 @@ export namespace FirebaseFirestoreTypes { } } -declare module '@react-native-firebase/firestore' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; - - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; - - const defaultExport: FirebaseModuleWithStaticsAndApp< - FirebaseFirestoreTypes.Module, - FirebaseFirestoreTypes.Statics - >; - export default defaultExport; -} +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp< + FirebaseFirestoreTypes.Module, + FirebaseFirestoreTypes.Statics +>; + +export const firebase: ReactNativeFirebase.Module & { + firestore: typeof defaultExport; + app( + name?: string, + ): ReactNativeFirebase.FirebaseApp & { firestore(): FirebaseFirestoreTypes.Module }; +}; + +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/functions/lib/index.d.ts b/packages/functions/lib/index.d.ts index 7bf0f343f1..d1c7ecb539 100644 --- a/packages/functions/lib/index.d.ts +++ b/packages/functions/lib/index.d.ts @@ -359,21 +359,19 @@ export namespace FirebaseFunctionsTypes { } } -declare module '@react-native-firebase/functions' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp< + FirebaseFunctionsTypes.Module, + FirebaseFunctionsTypes.Statics +>; - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; +export const firebase: ReactNativeFirebase.Module & { + functions: typeof defaultExport; + app( + name?: string, + ): ReactNativeFirebase.FirebaseApp & { functions(): FirebaseFunctionsTypes.Module }; +}; - const defaultExport: FirebaseModuleWithStaticsAndApp< - FirebaseFunctionsTypes.Module, - FirebaseFunctionsTypes.Statics - >; - export default defaultExport; -} +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/iid/lib/index.d.ts b/packages/iid/lib/index.d.ts index 2370a6d4cd..fab2763402 100644 --- a/packages/iid/lib/index.d.ts +++ b/packages/iid/lib/index.d.ts @@ -131,21 +131,17 @@ export namespace FirebaseIidTypes { } } -declare module '@react-native-firebase/iid' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp< + FirebaseIidTypes.Module, + FirebaseIidTypes.Statics +>; - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; +export const firebase: ReactNativeFirebase.Module & { + iid: typeof defaultExport; + app(name?: string): ReactNativeFirebase.FirebaseApp & { iid(): FirebaseIidTypes.Module }; +}; - const defaultExport: FirebaseModuleWithStaticsAndApp< - FirebaseIidTypes.Module, - FirebaseIidTypes.Statics - >; - export default defaultExport; -} +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/in-app-messaging/lib/index.d.ts b/packages/in-app-messaging/lib/index.d.ts index 28bd6aaf06..035a3d676f 100644 --- a/packages/in-app-messaging/lib/index.d.ts +++ b/packages/in-app-messaging/lib/index.d.ts @@ -147,21 +147,19 @@ export namespace FirebaseInAppMessagingTypes { } } -declare module '@react-native-firebase/in-app-messaging' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStatics< + FirebaseInAppMessagingTypes.Module, + FirebaseInAppMessagingTypes.Statics +>; - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; +export const firebase: ReactNativeFirebase.Module & { + inAppMessaging: typeof defaultExport; + app( + name?: string, + ): ReactNativeFirebase.FirebaseApp & { inAppMessaging(): FirebaseInAppMessagingTypes.Module }; +}; - const module: FirebaseModuleWithStatics< - FirebaseInAppMessagingTypes.Module, - FirebaseInAppMessagingTypes.Statics - >; - export default module; -} +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/messaging/lib/index.d.ts b/packages/messaging/lib/index.d.ts index f036f3b798..a27cc8abfe 100644 --- a/packages/messaging/lib/index.d.ts +++ b/packages/messaging/lib/index.d.ts @@ -949,21 +949,19 @@ export namespace FirebaseMessagingTypes { } } -declare module '@react-native-firebase/messaging' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; - - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; - - const defaultExport: FirebaseModuleWithStatics< - FirebaseMessagingTypes.Module, - FirebaseMessagingTypes.Statics - >; - export default defaultExport; -} +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStatics< + FirebaseMessagingTypes.Module, + FirebaseMessagingTypes.Statics +>; + +export const firebase: ReactNativeFirebase.Module & { + messaging: typeof defaultExport; + app( + name?: string, + ): ReactNativeFirebase.FirebaseApp & { messaging(): FirebaseMessagingTypes.Module }; +}; + +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/ml-natural-language/lib/index.d.ts b/packages/ml-natural-language/lib/index.d.ts index 2ec7452e44..06a1e4c2c9 100644 --- a/packages/ml-natural-language/lib/index.d.ts +++ b/packages/ml-natural-language/lib/index.d.ts @@ -224,21 +224,19 @@ export namespace FirebaseLanguageTypes { } } -declare module '@react-native-firebase/ml-natural-language' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp< + FirebaseLanguageTypes.Module, + FirebaseLanguageTypes.Statics +>; - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; +export const firebase: ReactNativeFirebase.Module & { + naturalLanguage: typeof defaultExport; + app( + name?: string, + ): ReactNativeFirebase.FirebaseApp & { naturalLanguage(): FirebaseLanguageTypes.Module }; +}; - const defaultExport: FirebaseModuleWithStaticsAndApp< - FirebaseLanguageTypes.Module, - FirebaseLanguageTypes.Statics - >; - export default defaultExport; -} +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/ml-vision/lib/index.d.ts b/packages/ml-vision/lib/index.d.ts index 156d3a236d..872d181305 100644 --- a/packages/ml-vision/lib/index.d.ts +++ b/packages/ml-vision/lib/index.d.ts @@ -1175,37 +1175,33 @@ export namespace FirebaseVisionTypes { } } -declare module '@react-native-firebase/ml-vision' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; - - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; - - export const VisionBarcodeFormat: {} & typeof FirebaseVisionTypes.VisionBarcodeFormat; - export const VisionFaceContourType: {} & typeof FirebaseVisionTypes.VisionFaceContourType; - export const VisionFaceLandmarkType: {} & typeof FirebaseVisionTypes.VisionFaceLandmarkType; - export const VisionBarcodeValueType: {} & typeof FirebaseVisionTypes.VisionBarcodeValueType; - export const VisionBarcodeEmailType: {} & typeof FirebaseVisionTypes.VisionBarcodeEmailType; - export const VisionBarcodePhoneType: {} & typeof FirebaseVisionTypes.VisionBarcodePhoneType; - export const VisionBarcodeAddressType: {} & typeof FirebaseVisionTypes.VisionBarcodeAddressType; - export const VisionFaceDetectorContourMode: {} & typeof FirebaseVisionTypes.VisionFaceDetectorContourMode; - export const VisionFaceDetectorLandmarkMode: {} & typeof FirebaseVisionTypes.VisionFaceDetectorLandmarkMode; - export const VisionBarcodeWifiEncryptionType: {} & FirebaseVisionTypes.VisionBarcodeWifiEncryptionType; - export const VisionFaceDetectorPerformanceMode: {} & typeof FirebaseVisionTypes.VisionFaceDetectorPerformanceMode; - export const VisionCloudTextRecognizerModelType: {} & typeof FirebaseVisionTypes.VisionCloudTextRecognizerModelType; - export const VisionFaceDetectorClassificationMode: {} & typeof FirebaseVisionTypes.VisionFaceDetectorClassificationMode; - export const VisionDocumentTextRecognizedBreakType: {} & typeof FirebaseVisionTypes.VisionDocumentTextRecognizedBreakType; - export const VisionCloudLandmarkRecognizerModelType: {} & typeof FirebaseVisionTypes.VisionCloudLandmarkRecognizerModelType; - - const defaultExport: FirebaseModuleWithStaticsAndApp< - FirebaseVisionTypes.Module, - FirebaseVisionTypes.Statics - >; - export default defaultExport; -} +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp< + FirebaseVisionTypes.Module, + FirebaseVisionTypes.Statics +>; + +export const firebase: ReactNativeFirebase.Module & { + analytics: typeof defaultExport; + app(name?: string): ReactNativeFirebase.FirebaseApp & { vision(): FirebaseVisionTypes.Module }; +}; + +export const VisionBarcodeFormat: typeof FirebaseVisionTypes.VisionBarcodeFormat; +export const VisionFaceContourType: typeof FirebaseVisionTypes.VisionFaceContourType; +export const VisionFaceLandmarkType: typeof FirebaseVisionTypes.VisionFaceLandmarkType; +export const VisionBarcodeValueType: typeof FirebaseVisionTypes.VisionBarcodeValueType; +export const VisionBarcodeEmailType: typeof FirebaseVisionTypes.VisionBarcodeEmailType; +export const VisionBarcodePhoneType: typeof FirebaseVisionTypes.VisionBarcodePhoneType; +export const VisionBarcodeAddressType: typeof FirebaseVisionTypes.VisionBarcodeAddressType; +export const VisionFaceDetectorContourMode: typeof FirebaseVisionTypes.VisionFaceDetectorContourMode; +export const VisionFaceDetectorLandmarkMode: typeof FirebaseVisionTypes.VisionFaceDetectorLandmarkMode; +export const VisionBarcodeWifiEncryptionType: typeof FirebaseVisionTypes.VisionBarcodeWifiEncryptionType; +export const VisionFaceDetectorPerformanceMode: typeof FirebaseVisionTypes.VisionFaceDetectorPerformanceMode; +export const VisionCloudTextRecognizerModelType: typeof FirebaseVisionTypes.VisionCloudTextRecognizerModelType; +export const VisionFaceDetectorClassificationMode: typeof FirebaseVisionTypes.VisionFaceDetectorClassificationMode; +export const VisionDocumentTextRecognizedBreakType: typeof FirebaseVisionTypes.VisionDocumentTextRecognizedBreakType; +export const VisionCloudLandmarkRecognizerModelType: typeof FirebaseVisionTypes.VisionCloudLandmarkRecognizerModelType; + +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/perf/lib/index.d.ts b/packages/perf/lib/index.d.ts index 5af08886da..48063f0d19 100644 --- a/packages/perf/lib/index.d.ts +++ b/packages/perf/lib/index.d.ts @@ -443,21 +443,17 @@ export namespace FirebasePerformanceTypes { } } -declare module '@react-native-firebase/perf' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; - - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; - - const defaultExport: FirebaseModuleWithStatics< - FirebasePerformanceTypes.Module, - FirebasePerformanceTypes.Statics - >; - export default defaultExport; -} +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStatics< + FirebasePerformanceTypes.Module, + FirebasePerformanceTypes.Statics +>; + +export const firebase: ReactNativeFirebase.Module & { + perf: typeof defaultExport; + app(name?: string): ReactNativeFirebase.FirebaseApp & { perf(): FirebasePerformanceTypes.Module }; +}; + +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/remote-config/lib/index.d.ts b/packages/remote-config/lib/index.d.ts index 8165d2e014..9d48256a4e 100644 --- a/packages/remote-config/lib/index.d.ts +++ b/packages/remote-config/lib/index.d.ts @@ -517,21 +517,19 @@ export namespace FirebaseRemoteConfigTypes { } } -declare module '@react-native-firebase/remote-config' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStatics< + FirebaseRemoteConfigTypes.Module, + FirebaseRemoteConfigTypes.Statics +>; - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; +export const firebase: ReactNativeFirebase.Module & { + remoteConfig: typeof defaultExport; + app( + name?: string, + ): ReactNativeFirebase.FirebaseApp & { remoteConfig(): FirebaseRemoteConfigTypes.Module }; +}; - const defaultExport: FirebaseModuleWithStatics< - FirebaseRemoteConfigTypes.Module, - FirebaseRemoteConfigTypes.Statics - >; - export default defaultExport; -} +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/packages/storage/lib/index.d.ts b/packages/storage/lib/index.d.ts index 79a5ecc06a..d6ae110a41 100644 --- a/packages/storage/lib/index.d.ts +++ b/packages/storage/lib/index.d.ts @@ -1097,21 +1097,17 @@ export namespace FirebaseStorageTypes { } } -declare module '@react-native-firebase/storage' { - // tslint:disable-next-line:no-duplicate-imports required otherwise doesn't work - import { ReactNativeFirebase } from '@react-native-firebase/app'; - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; - - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; - - const defaultExport: FirebaseModuleWithStaticsAndApp< - FirebaseStorageTypes.Module, - FirebaseStorageTypes.Statics - >; - export default defaultExport; -} +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp< + FirebaseStorageTypes.Module, + FirebaseStorageTypes.Statics +>; + +export const firebase: ReactNativeFirebase.Module & { + storage: typeof defaultExport; + app(name?: string): ReactNativeFirebase.FirebaseApp & { storage(): FirebaseStorageTypes.Module }; +}; + +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. diff --git a/scripts/_TEMPLATE_/lib/index.d.ts b/scripts/_TEMPLATE_/lib/index.d.ts index 4c65c20974..97d8e17aae 100644 --- a/scripts/_TEMPLATE_/lib/index.d.ts +++ b/scripts/_TEMPLATE_/lib/index.d.ts @@ -102,16 +102,17 @@ export namespace _Template_ { } } -declare module '@react-native-firebase/_template_' { - import ReactNativeFirebaseModule = ReactNativeFirebase.Module; - import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; +declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp< + _Template_.Module, + _Template_.Statics +>; - const firebaseNamedExport: {} & ReactNativeFirebaseModule; - export const firebase = firebaseNamedExport; +export const firebase: ReactNativeFirebase.Module & { + auth: typeof defaultExport; + app(name?: string): ReactNativeFirebase.FirebaseApp & { _template_(): _Template_.Module }; +}; - const module: FirebaseModuleWithStaticsAndApp<_Template_.Module, _Template_.Statics>; - export default module; -} +export default defaultExport; /** * Attach namespace to `firebase.` and `FirebaseApp.`. From bf9dd43416d89121aa6ff2aadb1a0040878534e3 Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 18:31:37 -0700 Subject: [PATCH 05/19] refactor(types): for JSON config, augment existing `ReactNativeFirebase` namespace from /app Re-exporting the namespace causes collision issues -- tramples previous values rather than merging --- packages/admob/lib/index.d.ts | 68 ++++++++++----------- packages/analytics/lib/index.d.ts | 52 ++++++++-------- packages/crashlytics/lib/index.d.ts | 12 ++-- packages/database/lib/index.d.ts | 50 ++++++++------- packages/in-app-messaging/lib/index.d.ts | 52 ++++++++-------- packages/messaging/lib/index.d.ts | 32 +++++----- packages/ml-natural-language/lib/index.d.ts | 22 +++---- packages/ml-vision/lib/index.d.ts | 16 +++-- packages/perf/lib/index.d.ts | 52 ++++++++-------- 9 files changed, 169 insertions(+), 187 deletions(-) diff --git a/packages/admob/lib/index.d.ts b/packages/admob/lib/index.d.ts index fdb97616d5..68aade6452 100644 --- a/packages/admob/lib/index.d.ts +++ b/packages/admob/lib/index.d.ts @@ -1218,41 +1218,39 @@ declare module '@react-native-firebase/app' { interface FirebaseApp { admob(): FirebaseAdMobTypes.Module; } - } -} - -namespace ReactNativeFirebase { - interface FirebaseJsonConfig { - /** - * The Google AdMob application App ID for Android. - * - * This can be found under: Apps > App settings > App ID on the Google AdMob dashboard. - * - * For testing purposes, use the App ID: `ca-app-pub-3940256099942544~3347511713`. - * - * @android - */ - admob_android_app_id: string; - - /** - * The Google AdMob application App ID for iOS. - * - * This can be found under: Apps > App settings > App ID on the Google AdMob dashboard. - * - * For testing purposes, use the App ID: `ca-app-pub-3940256099942544~1458002511`. - * - * @ios - */ - admob_ios_app_id: string; - /** - * By default, the Google Mobile Ads SDK initializes app measurement and begins sending user-level event data to - * Google immediately when the app starts. This initialization behavior ensures you can enable AdMob user metrics - * without making additional code changes. - * - * If you require your app users to provide consent before collecting data, setting the value to `true` will prevent - * data being sent until the `firebase.admob().initialize()` method has been called. - */ - admob_delay_app_measurement_init: boolean; + interface FirebaseJsonConfig { + /** + * The Google AdMob application App ID for Android. + * + * This can be found under: Apps > App settings > App ID on the Google AdMob dashboard. + * + * For testing purposes, use the App ID: `ca-app-pub-3940256099942544~3347511713`. + * + * @android + */ + admob_android_app_id: string; + + /** + * The Google AdMob application App ID for iOS. + * + * This can be found under: Apps > App settings > App ID on the Google AdMob dashboard. + * + * For testing purposes, use the App ID: `ca-app-pub-3940256099942544~1458002511`. + * + * @ios + */ + admob_ios_app_id: string; + + /** + * By default, the Google Mobile Ads SDK initializes app measurement and begins sending user-level event data to + * Google immediately when the app starts. This initialization behavior ensures you can enable AdMob user metrics + * without making additional code changes. + * + * If you require your app users to provide consent before collecting data, setting the value to `true` will prevent + * data being sent until the `firebase.admob().initialize()` method has been called. + */ + admob_delay_app_measurement_init: boolean; + } } } diff --git a/packages/analytics/lib/index.d.ts b/packages/analytics/lib/index.d.ts index c6b7664a2a..57afeea618 100644 --- a/packages/analytics/lib/index.d.ts +++ b/packages/analytics/lib/index.d.ts @@ -1510,33 +1510,31 @@ declare module '@react-native-firebase/app' { interface FirebaseApp { analytics(): FirebaseAnalyticsTypes.Module; } - } -} -namespace ReactNativeFirebase { - interface FirebaseJsonConfig { - /** - * Disable or enable auto collection of analytics data. - * - * This is useful for opt-in-first data flows, for example when dealing with GDPR compliance. - * This can be overridden in JavaScript. - * - * #### Example - * - * ```json - * // /firebase.json - * { - * "react-native": { - * "analytics_auto_collection_enabled": false - * } - * } - * ``` - * - * ```js - * // Re-enable analytics data collection, e.g. once user has granted permission: - * await firebase.analytics().setAnalyticsCollectionEnabled(true); - * ``` - */ - analytics_auto_collection_enabled: boolean; + interface FirebaseJsonConfig { + /** + * Disable or enable auto collection of analytics data. + * + * This is useful for opt-in-first data flows, for example when dealing with GDPR compliance. + * This can be overridden in JavaScript. + * + * #### Example + * + * ```json + * // /firebase.json + * { + * "react-native": { + * "analytics_auto_collection_enabled": false + * } + * } + * ``` + * + * ```js + * // Re-enable analytics data collection, e.g. once user has granted permission: + * await firebase.analytics().setAnalyticsCollectionEnabled(true); + * ``` + */ + analytics_auto_collection_enabled: boolean; + } } } diff --git a/packages/crashlytics/lib/index.d.ts b/packages/crashlytics/lib/index.d.ts index ed1ef6e829..62459baad3 100644 --- a/packages/crashlytics/lib/index.d.ts +++ b/packages/crashlytics/lib/index.d.ts @@ -278,13 +278,11 @@ declare module '@react-native-firebase/app' { interface FirebaseApp { crashlytics(): FirebaseCrashlyticsTypes.Module; } - } -} -namespace ReactNativeFirebase { - interface FirebaseJsonConfig { - crashlytics_ndk_enabled: boolean; - crashlytics_debug_enabled: boolean; - crashlytics_auto_collection_enabled: boolean; + interface FirebaseJsonConfig { + crashlytics_ndk_enabled: boolean; + crashlytics_debug_enabled: boolean; + crashlytics_auto_collection_enabled: boolean; + } } } diff --git a/packages/database/lib/index.d.ts b/packages/database/lib/index.d.ts index 8ae13aab40..9817646f92 100644 --- a/packages/database/lib/index.d.ts +++ b/packages/database/lib/index.d.ts @@ -1278,32 +1278,30 @@ declare module '@react-native-firebase/app' { interface FirebaseApp { database(databaseUrl?: string): FirebaseDatabaseTypes.Module; } - } -} -namespace ReactNativeFirebase { - interface FirebaseJsonConfig { - /** - * Set whether database persistence is enabled or disabled. - * - * This can be overridden in JavaScript, e.g. when requesting permission or on a condition. - * - * #### Example - * - * ```json - * // /firebase.json - * { - * "react-native": { - * "database_persistence_enabled": false - * } - * } - * ``` - * - * ```js - * // Re-enable database persistence - * await firebase.database().setPersistenceEnabled(true); - * ``` - */ - database_persistence_enabled: boolean; + interface FirebaseJsonConfig { + /** + * Set whether database persistence is enabled or disabled. + * + * This can be overridden in JavaScript, e.g. when requesting permission or on a condition. + * + * #### Example + * + * ```json + * // /firebase.json + * { + * "react-native": { + * "database_persistence_enabled": false + * } + * } + * ``` + * + * ```js + * // Re-enable database persistence + * await firebase.database().setPersistenceEnabled(true); + * ``` + */ + database_persistence_enabled: boolean; + } } } diff --git a/packages/in-app-messaging/lib/index.d.ts b/packages/in-app-messaging/lib/index.d.ts index 035a3d676f..ef6eb598b4 100644 --- a/packages/in-app-messaging/lib/index.d.ts +++ b/packages/in-app-messaging/lib/index.d.ts @@ -177,33 +177,31 @@ declare module '@react-native-firebase/app' { interface FirebaseApp { inAppMessaging(): FirebaseInAppMessagingTypes.Module; } - } -} -namespace ReactNativeFirebase { - interface FirebaseJsonConfig { - /** - * Disable or enable auto collection & receiving of in-app messages and data collection. - * - * This is useful for opt-in-first data flows, for example when dealing with GDPR compliance. - * This can be overridden in JavaScript. - * - * #### Example - * - * ```json - * // /firebase.json - * { - * "react-native": { - * "in_app_messaging_auto_collection_enabled": false - * } - * } - * ``` - * - * ```js - * // Re-enable in-app messaging, e.g. once user has granted permission: - * await firebase.inAppMessaging().setAutomaticDataCollectionEnabled(true); - * ``` - */ - in_app_messaging_auto_collection_enabled: boolean; + interface FirebaseJsonConfig { + /** + * Disable or enable auto collection & receiving of in-app messages and data collection. + * + * This is useful for opt-in-first data flows, for example when dealing with GDPR compliance. + * This can be overridden in JavaScript. + * + * #### Example + * + * ```json + * // /firebase.json + * { + * "react-native": { + * "in_app_messaging_auto_collection_enabled": false + * } + * } + * ``` + * + * ```js + * // Re-enable in-app messaging, e.g. once user has granted permission: + * await firebase.inAppMessaging().setAutomaticDataCollectionEnabled(true); + * ``` + */ + in_app_messaging_auto_collection_enabled: boolean; + } } } diff --git a/packages/messaging/lib/index.d.ts b/packages/messaging/lib/index.d.ts index a27cc8abfe..c1ba72ccfd 100644 --- a/packages/messaging/lib/index.d.ts +++ b/packages/messaging/lib/index.d.ts @@ -979,23 +979,21 @@ declare module '@react-native-firebase/app' { interface FirebaseApp { messaging(): FirebaseMessagingTypes.Module; } - } -} -namespace ReactNativeFirebase { - interface FirebaseJsonConfig { - messaging_auto_init_enabled?: boolean; - messaging_android_headless_task_timeout?: number; - messaging_android_notification_channel_id?: string; - messaging_android_notification_color?: string; - /** - * Whether RNFirebase Messaging automatically calls `[[UIApplication sharedApplication] registerForRemoteNotifications];` - * automatically on app launch (recommended) - defaults to true. - * - * If set to false; make sure to call `firebase.messaging().registerDeviceForRemoteMessages()` - * early on in your app startup - otherwise you will NOT receive remote messages/notifications - * in your app. - */ - messaging_ios_auto_register_for_remote_messages?: boolean; + interface FirebaseJsonConfig { + messaging_auto_init_enabled?: boolean; + messaging_android_headless_task_timeout?: number; + messaging_android_notification_channel_id?: string; + messaging_android_notification_color?: string; + /** + * Whether RNFirebase Messaging automatically calls `[[UIApplication sharedApplication] registerForRemoteNotifications];` + * automatically on app launch (recommended) - defaults to true. + * + * If set to false; make sure to call `firebase.messaging().registerDeviceForRemoteMessages()` + * early on in your app startup - otherwise you will NOT receive remote messages/notifications + * in your app. + */ + messaging_ios_auto_register_for_remote_messages?: boolean; + } } } diff --git a/packages/ml-natural-language/lib/index.d.ts b/packages/ml-natural-language/lib/index.d.ts index 06a1e4c2c9..ef4e4e12e6 100644 --- a/packages/ml-natural-language/lib/index.d.ts +++ b/packages/ml-natural-language/lib/index.d.ts @@ -255,19 +255,17 @@ declare module '@react-native-firebase/app' { interface FirebaseApp { naturalLanguage(): FirebaseLanguageTypes.Module; } - } -} -namespace ReactNativeFirebase { - interface FirebaseJsonConfig { - /** - * If `true`, the Language ID Model will be installed onto the device. - */ - ml_natural_language_language_id_model: boolean; + interface FirebaseJsonConfig { + /** + * If `true`, the Language ID Model will be installed onto the device. + */ + ml_natural_language_language_id_model: boolean; - /** - * If `true`, the Smart Reply Model will be installed onto the device. - */ - ml_natural_language_smart_reply_model: boolean; + /** + * If `true`, the Smart Reply Model will be installed onto the device. + */ + ml_natural_language_smart_reply_model: boolean; + } } } diff --git a/packages/ml-vision/lib/index.d.ts b/packages/ml-vision/lib/index.d.ts index 872d181305..0b2f3cf6d4 100644 --- a/packages/ml-vision/lib/index.d.ts +++ b/packages/ml-vision/lib/index.d.ts @@ -1219,15 +1219,13 @@ declare module '@react-native-firebase/app' { interface FirebaseApp { vision(): FirebaseVisionTypes.Module; } - } -} -namespace ReactNativeFirebase { - interface FirebaseJsonConfig { - ml_vision_face_model: boolean; - ml_vision_ocr_model: boolean; - ml_vision_barcode_model: boolean; - ml_vision_label_model: boolean; - ml_vision_image_label_model: boolean; + interface FirebaseJsonConfig { + ml_vision_face_model: boolean; + ml_vision_ocr_model: boolean; + ml_vision_barcode_model: boolean; + ml_vision_label_model: boolean; + ml_vision_image_label_model: boolean; + } } } diff --git a/packages/perf/lib/index.d.ts b/packages/perf/lib/index.d.ts index 48063f0d19..70241c8ab4 100644 --- a/packages/perf/lib/index.d.ts +++ b/packages/perf/lib/index.d.ts @@ -470,33 +470,31 @@ declare module '@react-native-firebase/app' { interface FirebaseApp { perf(): FirebasePerformanceTypes.Module; } - } -} -namespace ReactNativeFirebase { - interface FirebaseJsonConfig { - /** - * Disable or enable auto collection of performance monitoring data collection. - * - * This is useful for opt-in-first data flows, for example when dealing with GDPR compliance. - * This can be overridden in JavaScript. - * - * #### Example - * - * ```json - * // /firebase.json - * { - * "react-native": { - * "perf_auto_collection_enabled": false - * } - * } - * ``` - * - * ```js - * // Re-enable performance monitoring data collection, e.g. once user has granted permission: - * await firebase.perf().setPerformanceCollectionEnabled(true); - * ``` - */ - perf_auto_collection_enabled: boolean; + interface FirebaseJsonConfig { + /** + * Disable or enable auto collection of performance monitoring data collection. + * + * This is useful for opt-in-first data flows, for example when dealing with GDPR compliance. + * This can be overridden in JavaScript. + * + * #### Example + * + * ```json + * // /firebase.json + * { + * "react-native": { + * "perf_auto_collection_enabled": false + * } + * } + * ``` + * + * ```js + * // Re-enable performance monitoring data collection, e.g. once user has granted permission: + * await firebase.perf().setPerformanceCollectionEnabled(true); + * ``` + */ + perf_auto_collection_enabled: boolean; + } } } From 344380122a90836ffe5561d9f0f35e4cbe4b671d Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 22:46:12 -0700 Subject: [PATCH 06/19] fix(types, admob): Use string-indexing rather than dot-notation for referring to interface keys --- packages/admob/lib/index.d.ts | 52 ++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/packages/admob/lib/index.d.ts b/packages/admob/lib/index.d.ts index 68aade6452..921d2db4e6 100644 --- a/packages/admob/lib/index.d.ts +++ b/packages/admob/lib/index.d.ts @@ -398,9 +398,9 @@ export namespace FirebaseAdMobTypes { */ setDebugGeography( geography: - | AdsConsentDebugGeography.DISABLED - | AdsConsentDebugGeography.EEA - | AdsConsentDebugGeography.NOT_EEA, + | AdsConsentDebugGeography['DISABLED'] + | AdsConsentDebugGeography['EEA'] + | AdsConsentDebugGeography['NOT_EEA'], ): Promise; /** @@ -424,9 +424,9 @@ export namespace FirebaseAdMobTypes { */ setStatus( status: - | AdsConsentStatus.UNKNOWN - | AdsConsentStatus.NON_PERSONALIZED - | AdsConsentStatus.PERSONALIZED, + | AdsConsentStatus['UNKNOWN'] + | AdsConsentStatus['NON_PERSONALIZED'] + | AdsConsentStatus['PERSONALIZED'], ): Promise; /** @@ -443,7 +443,9 @@ export namespace FirebaseAdMobTypes { * ``` */ getStatus(): Promise< - AdsConsentStatus.UNKNOWN | AdsConsentStatus.NON_PERSONALIZED | AdsConsentStatus.PERSONALIZED + | AdsConsentStatus['UNKNOWN'] + | AdsConsentStatus['NON_PERSONALIZED'] + | AdsConsentStatus['PERSONALIZED'] >; /** @@ -537,9 +539,9 @@ export namespace FirebaseAdMobTypes { * - PERSONALIZED: The user has accepted personalized ads. */ status: - | AdsConsentStatus.UNKNOWN - | AdsConsentStatus.NON_PERSONALIZED - | AdsConsentStatus.PERSONALIZED; + | AdsConsentStatus['UNKNOWN'] + | AdsConsentStatus['NON_PERSONALIZED'] + | AdsConsentStatus['PERSONALIZED']; /** * If `true`, the user requested an ad-free version of your application. @@ -559,9 +561,9 @@ export namespace FirebaseAdMobTypes { * - PERSONALIZED: The user has accepted personalized ads. */ status: - | AdsConsentStatus.UNKNOWN - | AdsConsentStatus.NON_PERSONALIZED - | AdsConsentStatus.PERSONALIZED; + | AdsConsentStatus['UNKNOWN'] + | AdsConsentStatus['NON_PERSONALIZED'] + | AdsConsentStatus['PERSONALIZED']; /** * If `true` the user is within the EEA or their location could not be determined. @@ -768,10 +770,10 @@ export namespace FirebaseAdMobTypes { * Ratings are based on the [digital content label classifications](https://support.google.com/admob/answer/7562142). */ maxAdContentRating?: - | MaxAdContentRating.G - | MaxAdContentRating.PG - | MaxAdContentRating.T - | MaxAdContentRating.MA; + | MaxAdContentRating['G'] + | MaxAdContentRating['PG'] + | MaxAdContentRating['T'] + | MaxAdContentRating['MA']; /** * If `true`, indicates that you want your content treated as child-directed for purposes of COPPA. @@ -843,14 +845,14 @@ export namespace FirebaseAdMobTypes { */ export type AdEventListener = ( type: - | AdEventType.LOADED - | AdEventType.ERROR - | AdEventType.OPENED - | AdEventType.CLICKED - | AdEventType.LEFT_APPLICATION - | AdEventType.CLOSED - | RewardedAdEventType.LOADED - | RewardedAdEventType.EARNED_REWARD, + | AdEventType['LOADED'] + | AdEventType['ERROR'] + | AdEventType['OPENED'] + | AdEventType['CLICKED'] + | AdEventType['LEFT_APPLICATION'] + | AdEventType['CLOSED'] + | RewardedAdEventType['LOADED'] + | RewardedAdEventType['EARNED_REWARD'], error?: Error, data?: any | RewardedAdReward, ) => void; From 0ddff12a328b905a083f6cfa78f5fe48eca2a268 Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 17:43:18 -0700 Subject: [PATCH 07/19] fix(types, analytics): convert missing interface to `any` --- packages/analytics/lib/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/analytics/lib/index.d.ts b/packages/analytics/lib/index.d.ts index 57afeea618..077706683f 100644 --- a/packages/analytics/lib/index.d.ts +++ b/packages/analytics/lib/index.d.ts @@ -1262,7 +1262,7 @@ export namespace FirebaseAnalyticsTypes { * * @param params See {@link analytics.SetCheckoutOptionEventParameters}. */ - logSetCheckoutOption(params: SetCheckoutOptionEventParameters): Promise; + logSetCheckoutOption(params: any): Promise; /** * Share event. Apps with social features can log the Share event to identify the most viral content. From af23dbb18971c1c797a76f57f5e8250ff22aec15 Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 19:07:33 -0700 Subject: [PATCH 08/19] fix(types, database): missing `value` type (treated as 'any') --- packages/database/lib/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/database/lib/index.d.ts b/packages/database/lib/index.d.ts index 9817646f92..31316ceb95 100644 --- a/packages/database/lib/index.d.ts +++ b/packages/database/lib/index.d.ts @@ -264,7 +264,7 @@ export namespace FirebaseDatabaseTypes { * @param values Object containing multiple values. * @param onComplete Callback called when write to server is complete. Contains the parameters (Error | null). */ - update(values: { [key: string]: value }, onComplete?: Function): Promise; + update(values: { [key: string]: any }, onComplete?: Function): Promise; /** * Sets a priority for the data at this Database location. Setting null removes any priority at this location. @@ -915,7 +915,7 @@ export namespace FirebaseDatabaseTypes { * @param values Object containing multiple values. * @param onComplete An optional callback function that will be called when synchronization to the server has completed. The callback will be passed a single parameter: null for success, or an Error object indicating a failure. */ - update(values: { [key: string]: value }, onComplete?: Function): Promise; + update(values: { [key: string]: any }, onComplete?: Function): Promise; } export type EventType = From b85c6b464e78c20c4e81e329512826894be96f20 Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 19:28:10 -0700 Subject: [PATCH 09/19] fix(types, dynamic-links): fix dynamic-links `onLink` function type "Function" is not generic --- packages/dynamic-links/lib/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dynamic-links/lib/index.d.ts b/packages/dynamic-links/lib/index.d.ts index a51e648fa3..0083f6f632 100644 --- a/packages/dynamic-links/lib/index.d.ts +++ b/packages/dynamic-links/lib/index.d.ts @@ -540,7 +540,7 @@ export namespace FirebaseDynamicLinksTypes { * @returns Unsubscribe function, call the returned function to unsubscribe from all future events. * @param listener The listener callback, called with Dynamic Link instances. */ - onLink(listener: Function): Function; + onLink(listener: (link: DynamicLink) => void): Function; /** * Resolve a given dynamic link (short or long) directly. From 0aeddbe956ffdf919c365e4e940d1ce3b28bb6a6 Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 19:19:04 -0700 Subject: [PATCH 10/19] fix(types, firestore): add missing generic to Promise type Keep current behavior with `any` --- packages/firestore/lib/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firestore/lib/index.d.ts b/packages/firestore/lib/index.d.ts index b557458647..0c17e0dbef 100644 --- a/packages/firestore/lib/index.d.ts +++ b/packages/firestore/lib/index.d.ts @@ -1962,7 +1962,7 @@ export namespace FirebaseFirestoreTypes { * }); * ``` */ - runTransaction(updateFunction: (transaction: Transaction) => Promise): Promise; + runTransaction(updateFunction: (transaction: Transaction) => Promise): Promise; /** * Specifies custom settings to be used to configure the Firestore instance. Must be set before invoking any other methods. From 41fc0355585ac140a4cb848bae02b07a015066a6 Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 19:30:41 -0700 Subject: [PATCH 11/19] fix(types, messaging): remove parameter initializer in typedef Only allowed in implementations --- packages/messaging/lib/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/messaging/lib/index.d.ts b/packages/messaging/lib/index.d.ts index c1ba72ccfd..cbf133ddad 100644 --- a/packages/messaging/lib/index.d.ts +++ b/packages/messaging/lib/index.d.ts @@ -608,7 +608,7 @@ export namespace FirebaseMessagingTypes { * @param authorizedEntity The messaging sender ID. In most cases this will be the current default app. * @param scope The scope to assign a token, which the sever can use to target messages at. */ - getToken(authorizedEntity?: string, scope?: string = 'FCM'): Promise; + getToken(authorizedEntity?: string, scope?: string): Promise; /** * Removes access to an FCM token previously authorized by it's scope. Messages sent by the server @@ -623,7 +623,7 @@ export namespace FirebaseMessagingTypes { * @param authorizedEntity The messaging sender ID. In most cases this will be the current default app. * @param scope The scope to assign when token will be deleted. */ - deleteToken(authorizedEntity?: string, scope?: string = 'FCM'): Promise; + deleteToken(authorizedEntity?: string, scope?: string): Promise; /** * When any FCM payload is received, the listener callback is called with a `RemoteMessage`. From f6ef17ff48335ba612baca78c234b17dc0853a76 Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 19:31:13 -0700 Subject: [PATCH 12/19] fix(types, messaging): avoid implicit `any` via `void` return type for `setBackgroundMessageHandler` --- packages/messaging/lib/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/messaging/lib/index.d.ts b/packages/messaging/lib/index.d.ts index cbf133ddad..1d89b7adbb 100644 --- a/packages/messaging/lib/index.d.ts +++ b/packages/messaging/lib/index.d.ts @@ -897,7 +897,7 @@ export namespace FirebaseMessagingTypes { * ``` * */ - setBackgroundMessageHandler(handler: (message: RemoteMessage) => Promise); + setBackgroundMessageHandler(handler: (message: RemoteMessage) => Promise): void; /** * Send a new `RemoteMessage` to the FCM server. From 193bc330055308ee2d2521eb470fb2ae3a0c9696 Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 22:48:23 -0700 Subject: [PATCH 13/19] fix(types, ml-vision): import non-ambient types in BarcodeDetectorTypes --- packages/ml-vision/lib/BarcodeDetectorTypes.d.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/ml-vision/lib/BarcodeDetectorTypes.d.ts b/packages/ml-vision/lib/BarcodeDetectorTypes.d.ts index 041202d5b8..8e0cce321f 100644 --- a/packages/ml-vision/lib/BarcodeDetectorTypes.d.ts +++ b/packages/ml-vision/lib/BarcodeDetectorTypes.d.ts @@ -1,3 +1,5 @@ +import { FirebaseVisionTypes } from '.'; + /** * Firebase ML Kit package for React Native. * @@ -49,12 +51,12 @@ export namespace MLKitVision { /** * Returns the bounding rectangle of the detected barcode. */ - boundingBox: VisionRectangle; + boundingBox: FirebaseVisionTypes.VisionRectangle; /** * Gets the four corner points in clockwise direction starting with top-left. Due to the possible perspective distortions, this is not necessarily a rectangle. Parts of the region could be outside of the image. */ - cornerPoints: VisionPoint[]; + cornerPoints: FirebaseVisionTypes.VisionPoint[]; /** * Returns the barcode format, for example `VisionBarcodeFormat.QR_CODE` @@ -178,7 +180,7 @@ export namespace MLKitVision { * } * ``` */ - geoPoint?: VisionGeoPoint; + geoPoint?: FirebaseVisionTypes.VisionGeoPoint; /** * Gets parsed phone details (set if `valueType` is `VisionBarcodeValueType.PHONE`). From a099110e4ee841582f0dbd5368964795af700700 Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 22:51:08 -0700 Subject: [PATCH 14/19] fix(types, ml-vision): import non-ambient types in root module from BarcodeDetectorTypes --- packages/ml-vision/lib/index.d.ts | 48 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/ml-vision/lib/index.d.ts b/packages/ml-vision/lib/index.d.ts index 0b2f3cf6d4..4261874a25 100644 --- a/packages/ml-vision/lib/index.d.ts +++ b/packages/ml-vision/lib/index.d.ts @@ -16,7 +16,7 @@ */ import { ReactNativeFirebase } from '@react-native-firebase/app'; - +import { MLKitVision } from './BarcodeDetectorTypes'; /** * Firebase ML Kit package for React Native. * @@ -66,12 +66,12 @@ export namespace FirebaseVisionTypes { VisionFaceContourType: typeof VisionFaceContourType; VisionCloudLandmarkRecognizerModelType: typeof VisionCloudLandmarkRecognizerModelType; VisionDocumentTextRecognizedBreakType: typeof VisionDocumentTextRecognizedBreakType; - VisionBarcodeFormat: typeof VisionBarcodeFormat; - VisionBarcodeValueType: typeof VisionBarcodeValueType; - VisionBarcodeAddressType: typeof VisionBarcodeAddressType; - VisionBarcodeEmailType: typeof VisionBarcodeEmailType; - VisionBarcodePhoneType: typeof VisionBarcodePhoneType; - VisionBarcodeWifiEncryptionType: typeof VisionBarcodeWifiEncryptionType; + VisionBarcodeFormat: typeof MLKitVision.VisionBarcodeFormat; + VisionBarcodeValueType: typeof MLKitVision.VisionBarcodeValueType; + VisionBarcodeAddressType: typeof MLKitVision.VisionBarcodeAddressType; + VisionBarcodeEmailType: typeof MLKitVision.VisionBarcodeEmailType; + VisionBarcodePhoneType: typeof MLKitVision.VisionBarcodePhoneType; + VisionBarcodeWifiEncryptionType: typeof MLKitVision.VisionBarcodeWifiEncryptionType; } /** @@ -1170,8 +1170,8 @@ export namespace FirebaseVisionTypes { */ barcodeDetectorProcessImage( imageFilePath: string, - barcodeDetectorOptions?: VisionBarcodeDetectorOptions, - ): Promise; + barcodeDetectorOptions?: MLKitVision.VisionBarcodeDetectorOptions, + ): Promise; } } @@ -1185,21 +1185,21 @@ export const firebase: ReactNativeFirebase.Module & { app(name?: string): ReactNativeFirebase.FirebaseApp & { vision(): FirebaseVisionTypes.Module }; }; -export const VisionBarcodeFormat: typeof FirebaseVisionTypes.VisionBarcodeFormat; -export const VisionFaceContourType: typeof FirebaseVisionTypes.VisionFaceContourType; -export const VisionFaceLandmarkType: typeof FirebaseVisionTypes.VisionFaceLandmarkType; -export const VisionBarcodeValueType: typeof FirebaseVisionTypes.VisionBarcodeValueType; -export const VisionBarcodeEmailType: typeof FirebaseVisionTypes.VisionBarcodeEmailType; -export const VisionBarcodePhoneType: typeof FirebaseVisionTypes.VisionBarcodePhoneType; -export const VisionBarcodeAddressType: typeof FirebaseVisionTypes.VisionBarcodeAddressType; -export const VisionFaceDetectorContourMode: typeof FirebaseVisionTypes.VisionFaceDetectorContourMode; -export const VisionFaceDetectorLandmarkMode: typeof FirebaseVisionTypes.VisionFaceDetectorLandmarkMode; -export const VisionBarcodeWifiEncryptionType: typeof FirebaseVisionTypes.VisionBarcodeWifiEncryptionType; -export const VisionFaceDetectorPerformanceMode: typeof FirebaseVisionTypes.VisionFaceDetectorPerformanceMode; -export const VisionCloudTextRecognizerModelType: typeof FirebaseVisionTypes.VisionCloudTextRecognizerModelType; -export const VisionFaceDetectorClassificationMode: typeof FirebaseVisionTypes.VisionFaceDetectorClassificationMode; -export const VisionDocumentTextRecognizedBreakType: typeof FirebaseVisionTypes.VisionDocumentTextRecognizedBreakType; -export const VisionCloudLandmarkRecognizerModelType: typeof FirebaseVisionTypes.VisionCloudLandmarkRecognizerModelType; +export const VisionBarcodeFormat: FirebaseVisionTypes.Statics['VisionBarcodeFormat']; +export const VisionFaceContourType: FirebaseVisionTypes.Statics['VisionFaceContourType']; +export const VisionFaceLandmarkType: FirebaseVisionTypes.Statics['VisionFaceLandmarkType']; +export const VisionBarcodeValueType: FirebaseVisionTypes.Statics['VisionBarcodeValueType']; +export const VisionBarcodeEmailType: FirebaseVisionTypes.Statics['VisionBarcodeEmailType']; +export const VisionBarcodePhoneType: FirebaseVisionTypes.Statics['VisionBarcodePhoneType']; +export const VisionBarcodeAddressType: FirebaseVisionTypes.Statics['VisionBarcodeAddressType']; +export const VisionFaceDetectorContourMode: FirebaseVisionTypes.Statics['VisionFaceDetectorContourMode']; +export const VisionFaceDetectorLandmarkMode: FirebaseVisionTypes.Statics['VisionFaceDetectorLandmarkMode']; +export const VisionBarcodeWifiEncryptionType: FirebaseVisionTypes.Statics['VisionBarcodeWifiEncryptionType']; +export const VisionFaceDetectorPerformanceMode: FirebaseVisionTypes.Statics['VisionFaceDetectorPerformanceMode']; +export const VisionCloudTextRecognizerModelType: FirebaseVisionTypes.Statics['VisionCloudTextRecognizerModelType']; +export const VisionFaceDetectorClassificationMode: FirebaseVisionTypes.Statics['VisionFaceDetectorClassificationMode']; +export const VisionDocumentTextRecognizedBreakType: FirebaseVisionTypes.Statics['VisionDocumentTextRecognizedBreakType']; +export const VisionCloudLandmarkRecognizerModelType: FirebaseVisionTypes.Statics['VisionCloudLandmarkRecognizerModelType']; export default defaultExport; From bf5f36c1ec628acbb5af78363216647b486f37db Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 22:52:18 -0700 Subject: [PATCH 15/19] fix(types, ml-vision): repair invalid `extends` use by duplicating inherited key Could have Omit<>'ed the incompatible `bounds` key, but duplicating the one inherited key seemed less complex --- packages/ml-vision/lib/index.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/ml-vision/lib/index.d.ts b/packages/ml-vision/lib/index.d.ts index 4261874a25..dd18c28578 100644 --- a/packages/ml-vision/lib/index.d.ts +++ b/packages/ml-vision/lib/index.d.ts @@ -671,7 +671,12 @@ export namespace FirebaseVisionTypes { /** * A hierarchical representation of document text recognized in an image. */ - export interface VisionDocumentText extends VisionText { + export interface VisionDocumentText { + /** + * Retrieve the recognized text as a string. + */ + text: string; + /** * Gets an array `VisionTextBlock`, which is a block of text that can be further decomposed to an array of `VisionDocumentTextParagraph`. */ From 03ddd884877a54f634b6914fdd683ae33db413b6 Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 22:50:10 -0700 Subject: [PATCH 16/19] fix(types, perf): add void return types to untyped perf methods --- packages/perf/lib/index.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/perf/lib/index.d.ts b/packages/perf/lib/index.d.ts index 70241c8ab4..f1035b8815 100644 --- a/packages/perf/lib/index.d.ts +++ b/packages/perf/lib/index.d.ts @@ -109,7 +109,7 @@ export namespace FirebasePerformanceTypes { * @param attribute Name of the attribute. Max length is 40 chars. * @param value Value of the attribute. Max length is 100 chars. */ - putAttribute(attribute: string, value: string); + putAttribute(attribute: string, value: string): void; /** * Gets the value of the metric with the given name in the current trace. If the metric @@ -155,7 +155,7 @@ export namespace FirebasePerformanceTypes { * @param metricName Name of the metric to set. Must not have a leading or trailing whitespace, no leading underscore '_' character and have a max length of 32 characters. * @param value The value the metric should be set to. */ - putMetric(metricName: string, value: number); + putMetric(metricName: string, value: number): void; /** * Increments the named metric by the `incrementBy` value. @@ -169,7 +169,7 @@ export namespace FirebasePerformanceTypes { * @param metricName Name of the metric to increment. Must not have a leading or trailing whitespace, no leading underscore '_' character and have a max length of 32 characters. * @param incrementBy The value the metric should be incremented by. */ - incrementMetric(metricName: string, incrementBy: number); + incrementMetric(metricName: string, incrementBy: number): void; /** * Removes a metric by name if it exists. @@ -182,7 +182,7 @@ export namespace FirebasePerformanceTypes { * * @param metricName Name of the metric to remove. */ - removeMetric(metricName: string); + removeMetric(metricName: string): void; /** * Marks the start time of the trace. Does nothing if already started. @@ -256,7 +256,7 @@ export namespace FirebasePerformanceTypes { * @param attribute Name of the attribute. Max length is 40 chars. * @param value Value of the attribute. Max length is 100 chars. */ - putAttribute(attribute: string, value: string); + putAttribute(attribute: string, value: string): void; /** * Removes an already added attribute. Does nothing if attribute does not exist. @@ -269,7 +269,7 @@ export namespace FirebasePerformanceTypes { * * @param attribute Name of the attribute to be removed. */ - removeAttribute(attribute: string); + removeAttribute(attribute: string): void; /** * Sets the httpResponse code of the request. @@ -285,7 +285,7 @@ export namespace FirebasePerformanceTypes { * * @param code Value must be greater than 0. Set to null to remove. Invalid usage will be logged natively. */ - setHttpResponseCode(code: number | null); + setHttpResponseCode(code: number | null): void; /** * Sets the size of the request payload. @@ -299,7 +299,7 @@ export namespace FirebasePerformanceTypes { * * @param bytes Value must be greater than 0. Set to null to remove. Invalid usage will be logged natively. */ - setRequestPayloadSize(bytes: number | null); + setRequestPayloadSize(bytes: number | null): void; /** * Sets the size of the response payload. @@ -313,7 +313,7 @@ export namespace FirebasePerformanceTypes { * * @param bytes Value must be greater than 0. Set to null to remove. Invalid usage will be logged natively. */ - setResponsePayloadSize(bytes: number | null); + setResponsePayloadSize(bytes: number | null): void; /** * Content type of the response e.g. `text/html` or `application/json`. @@ -327,7 +327,7 @@ export namespace FirebasePerformanceTypes { * * @param contentType Valid string of MIME type. Set to null to remove. Invalid usage will be logged natively. */ - setResponseContentType(contentType: string | null); + setResponseContentType(contentType: string | null): void; /** * Marks the start time of the request. Does nothing if already started. From d5644c512f5c148b2b04f8bd54e9b134cd1ce0c6 Mon Sep 17 00:00:00 2001 From: David Govea Date: Thu, 24 Sep 2020 22:47:56 -0700 Subject: [PATCH 17/19] tests(admob): add type override to intentionally-wrong syntax Incorrect type is now caught by TS --- packages/admob/__tests__/admob.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/admob/__tests__/admob.test.ts b/packages/admob/__tests__/admob.test.ts index f9b940cbe7..0b03d94f38 100644 --- a/packages/admob/__tests__/admob.test.ts +++ b/packages/admob/__tests__/admob.test.ts @@ -1,4 +1,4 @@ -import { firebase } from '../lib'; +import { firebase, FirebaseAdMobTypes } from '../lib'; describe('Admob', () => { describe('namespace', () => { @@ -21,7 +21,7 @@ describe('Admob', () => { it('throws if maxAdContentRating is invalid', () => { expect(() => firebase.admob().setRequestConfiguration({ - maxAdContentRating: 'Y', + maxAdContentRating: 'Y' as FirebaseAdMobTypes.MaxAdContentRating[keyof FirebaseAdMobTypes.MaxAdContentRating], }), ).toThrowError( "firebase.admob().setRequestConfiguration(*) 'requestConfiguration.maxAdContentRating' expected on of MaxAdContentRating.G, MaxAdContentRating.PG, MaxAdContentRating.T or MaxAdContentRating.MA", From c2e80237ceb09d70e393f13f6e0d7510eeb40b63 Mon Sep 17 00:00:00 2001 From: David Govea Date: Fri, 25 Sep 2020 00:59:51 -0700 Subject: [PATCH 18/19] tests(types, ml-vision): fix ml-vision test typo, exposed by proper types VisionBarcodeFormat.ALL_POINTS does not exist --- packages/ml-vision/type-test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ml-vision/type-test.ts b/packages/ml-vision/type-test.ts index 0617960082..c1c480303a 100644 --- a/packages/ml-vision/type-test.ts +++ b/packages/ml-vision/type-test.ts @@ -27,7 +27,7 @@ console.log(firebase.vision(firebase.app()).app.name); // checks default export supports app arg console.log(firebase.vision(firebase.app('foo')).app.name); -console.log(firebase.vision.VisionBarcodeFormat.ALL_POINTS); +console.log(firebase.vision.VisionBarcodeFormat.ALL_FORMATS); console.log(vision.VisionBarcodeFormat); console.log(firebase.vision.VisionFaceContourType.ALL_POINTS); From 176fb12fef514c2dbb24f91b1ca10c0cb1b08129 Mon Sep 17 00:00:00 2001 From: David Govea Date: Mon, 28 Sep 2020 10:24:15 -0700 Subject: [PATCH 19/19] chore(website): update typedoc to allow recursive types uses new syntax: TSConfigReader --- website/package.json | 2 +- website/scripts/generate-typedoc.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/website/package.json b/website/package.json index d28bc8d2c6..aaf2ffdc41 100644 --- a/website/package.json +++ b/website/package.json @@ -37,7 +37,7 @@ "tailwindcss": "^1.4.0", "tailwindcss-dark-mode": "^1.1.0", "traverse": "^0.6.6", - "typedoc": "0.15.0", + "typedoc": "~0.19.2", "typescript": "^3.7.5", "use-dark-mode": "^2.3.1" }, diff --git a/website/scripts/generate-typedoc.js b/website/scripts/generate-typedoc.js index b69d19810a..098c615ed5 100644 --- a/website/scripts/generate-typedoc.js +++ b/website/scripts/generate-typedoc.js @@ -17,10 +17,11 @@ const { readFileSync, unlinkSync } = require('fs'); const path = require('path'); -const { Application } = require('typedoc'); +const { Application, TSConfigReader } = require('typedoc'); const tempOutput = path.resolve(process.cwd(), 'typedoc.json'); const app = new Application(); +app.options.addReader(new TSConfigReader()); module.exports.generateTypedoc = function generateTypedoc() { console.log(path.resolve(__dirname, '../../tsconfig.json'));