From 7e9644b6bea8e43cd67a07096c894da1ec985c44 Mon Sep 17 00:00:00 2001 From: davidgovea Date: Wed, 30 Sep 2020 12:49:16 -0700 Subject: [PATCH] fix(types): enable TypeScript libCheck & resolve type conflicts (#4306) * chore: enable TypeScript libcheck & remove "dom" lib "dom" conflicts with @types/react-native * chore: add react types (referenced by admob types) * refactor(types, app): move "app" exports to top-level exports, rather than module declarations with namespace extensions * refactor(types): use top-level exports for module types, rather than declarations * refactor(types): for JSON config, augment existing `ReactNativeFirebase` namespace from /app Re-exporting the namespace causes collision issues -- tramples previous values rather than merging * fix(types, admob): Use string-indexing rather than dot-notation for referring to interface keys * fix(types, analytics): convert missing interface to `any` * fix(types, database): missing `value` type (treated as 'any') * fix(types, dynamic-links): fix dynamic-links `onLink` function type "Function" is not generic * fix(types, firestore): add missing generic to Promise type Keep current behavior with `any` * fix(types, messaging): remove parameter initializer in typedef Only allowed in implementations * fix(types, messaging): avoid implicit `any` via `void` return type for `setBackgroundMessageHandler` * fix(types, ml-vision): import non-ambient types in BarcodeDetectorTypes * fix(types, ml-vision): import non-ambient types in root module from BarcodeDetectorTypes * 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 * fix(types, perf): add void return types to untyped perf methods * tests(admob): add type override to intentionally-wrong syntax Incorrect type is now caught by TS * tests(types, ml-vision): fix ml-vision test typo, exposed by proper types VisionBarcodeFormat.ALL_POINTS does not exist * chore(website): update typedoc to allow recursive types uses new syntax: TSConfigReader --- lib/index.d.ts | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/lib/index.d.ts b/lib/index.d.ts index 93320d9621..ee81e45e12 100644 --- a/lib/index.d.ts +++ b/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;