Skip to content

Commit 5f432f5

Browse files
committed
fix: type defs
1 parent 9a4ae52 commit 5f432f5

File tree

7 files changed

+125
-182
lines changed

7 files changed

+125
-182
lines changed

packages/app-distribution/lib/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ export type {
2020
AppDistributionRelease,
2121
FirebaseAppDistribution,
2222
FirebaseApp,
23+
FirebaseAppDistributionTypes,
2324
} from './types/app-distribution';
2425

25-
// Export types from types.d.ts
26-
export type { FirebaseAppDistributionTypes } from './types.d';
27-
2826
// Export modular API functions
2927
export * from './modular';
3028

packages/app-distribution/lib/namespaced.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
getFirebaseRoot,
2323
} from '@react-native-firebase/app/lib/internal';
2424
import { version } from './version';
25-
import type { FirebaseAppDistributionTypes } from './types.d';
25+
import type { FirebaseAppDistributionTypes } from './types/app-distribution';
2626

2727
const statics = {};
2828

@@ -33,6 +33,7 @@ const nativeModuleName = 'RNFBAppDistributionModule';
3333
class FirebaseAppDistributionModule extends FirebaseModule {
3434
isTesterSignedIn(_modularDeprecationArg?: any): Promise<boolean> {
3535
if (isIOS) {
36+
// @ts-ignore - native is inherited from FirebaseModule
3637
return this.native.isTesterSignedIn();
3738
}
3839

@@ -41,6 +42,7 @@ class FirebaseAppDistributionModule extends FirebaseModule {
4142

4243
signInTester(_modularDeprecationArg?: any): Promise<void> {
4344
if (isIOS) {
45+
// @ts-ignore - native is inherited from FirebaseModule
4446
return this.native.signInTester();
4547
}
4648

@@ -51,6 +53,7 @@ class FirebaseAppDistributionModule extends FirebaseModule {
5153
_modularDeprecationArg?: any,
5254
): Promise<FirebaseAppDistributionTypes.AppDistributionRelease> {
5355
if (isIOS) {
56+
// @ts-ignore - native is inherited from FirebaseModule
5457
return this.native.checkForUpdate();
5558
}
5659

@@ -59,6 +62,7 @@ class FirebaseAppDistributionModule extends FirebaseModule {
5962

6063
signOutTester(_modularDeprecationArg?: any): Promise<void> {
6164
if (isIOS) {
65+
// @ts-ignore - native is inherited from FirebaseModule
6266
return this.native.signOutTester();
6367
}
6468

Lines changed: 18 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -1,186 +1,31 @@
11
/*
2-
* Copyright (c) 2016-present Invertase Limited & Contributors
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this library except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*
2+
* Type declarations for modules from @react-native-firebase/app
3+
* These are JavaScript modules that don't have type definitions
164
*/
175

18-
import { ReactNativeFirebase } from '@react-native-firebase/app';
19-
20-
/**
21-
* Firebase AppDistribution package for React Native.
22-
*
23-
* #### Example 1
24-
*
25-
* Access the firebase export from the `app-distribution` package:
26-
*
27-
* ```js
28-
* import { firebase } from '@react-native-firebase/app-distribution';
29-
*
30-
* // firebase.appDistribution().X
31-
* ```
32-
*
33-
* #### Example 2
34-
*
35-
* Using the default export from the `app-distribution` package:
36-
*
37-
* ```js
38-
* import appDistribution from '@react-native-firebase/app-distribution';
39-
*
40-
* // appDistribution().X
41-
* ```
42-
*
43-
* #### Example 3
44-
*
45-
* Using the default export from the `app` package:
46-
*
47-
* ```js
48-
* import firebase from '@react-native-firebase/app';
49-
* import '@react-native-firebase/app-distribution';
50-
*
51-
* // firebase.appDistribution().X
52-
* ```
53-
*
54-
* @firebase app-distribution
55-
*/
56-
export namespace FirebaseAppDistributionTypes {
57-
import FirebaseModule = ReactNativeFirebase.FirebaseModule;
58-
59-
/**
60-
* The release information returned by the update check when a new version is available.
61-
*/
62-
export interface AppDistributionRelease {
63-
/**
64-
* The short bundle version of this build (example 1.0.0).
65-
*/
66-
displayVersion: string;
67-
68-
/**
69-
* The build number of this build (example: 123).
70-
*/
71-
buildVersion: string;
72-
73-
/**
74-
* The release notes for this build, possibly null if no release notes were provided.
75-
*/
76-
releaseNotes: string | null;
77-
78-
/**
79-
* The URL for the build.
80-
*/
81-
downloadURL: string;
82-
83-
/**
84-
* Whether the download URL for this release is expired.
85-
*/
86-
isExpired: boolean;
87-
}
88-
89-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
90-
export interface Statics {
91-
// firebase.appDistribution.* static props go here
92-
}
93-
94-
/**
95-
* The Firebase AppDistribution service interface.
96-
*
97-
* > This module is available for the default app only.
98-
*
99-
* #### Example
100-
*
101-
* Get the AppDistribution service for the default app:
102-
*
103-
* ```js
104-
* const defaultAppAppDistribution = firebase.appDistribution();
105-
* ```
106-
*/
107-
export class Module extends FirebaseModule {
108-
/**
109-
* Returns true if the App Distribution tester is signed in.
110-
* If not an iOS device, it always rejects, as neither false nor true seem like a sensible default.
111-
*/
112-
isTesterSignedIn(_modularDeprecationArg?: any): Promise<boolean>;
113-
114-
/**
115-
* Sign-in the App Distribution tester
116-
* If not an iOS device, it always rejects, as no defaults seem sensible.
117-
*/
118-
signInTester(_modularDeprecationArg?: any): Promise<void>;
119-
120-
/**
121-
* Check to see whether a new distribution is available
122-
* If not an iOS device, it always rejects, as no default response seems sensible.
123-
*/
124-
checkForUpdate(_modularDeprecationArg?: any): Promise<AppDistributionRelease>;
125-
126-
/**
127-
* Sign out App Distribution tester
128-
* If not an iOS device, it always rejects, as no default response seems sensible.
129-
*/
130-
signOutTester(_modularDeprecationArg?: any): Promise<void>;
131-
}
132-
}
133-
134-
declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp<
135-
FirebaseAppDistributionTypes.Module,
136-
FirebaseAppDistributionTypes.Statics
137-
>;
138-
139-
export const firebase: ReactNativeFirebase.Module & {
140-
appDistribution: typeof defaultExport;
141-
app(
142-
name?: string,
143-
): ReactNativeFirebase.FirebaseApp & { appDistribution(): FirebaseAppDistributionTypes.Module };
144-
};
145-
146-
export default defaultExport;
147-
148-
export * from './modular';
149-
150-
/**
151-
* Attach namespace to `firebase.` and `FirebaseApp.`.
152-
*/
153-
declare module '@react-native-firebase/app' {
154-
namespace ReactNativeFirebase {
155-
import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp;
156-
interface Module {
157-
appDistribution: FirebaseModuleWithStaticsAndApp<
158-
FirebaseAppDistributionTypes.Module,
159-
FirebaseAppDistributionTypes.Statics
160-
>;
161-
}
162-
interface FirebaseApp {
163-
appDistribution(): FirebaseAppDistributionTypes.Module;
164-
readonly name: string;
165-
}
166-
}
167-
168-
export function getApp(appName?: string): ReactNativeFirebase.FirebaseApp;
169-
}
170-
1716
declare module '@react-native-firebase/app/lib/common' {
172-
export const MODULAR_DEPRECATION_ARG: string;
1737
export const isIOS: boolean;
8+
export const isAndroid: boolean;
9+
export const MODULAR_DEPRECATION_ARG: any;
17410
}
17511

17612
declare module '@react-native-firebase/app/lib/internal' {
177-
export function createModuleNamespace(config: any): any;
13+
export function createModuleNamespace(options: {
14+
statics: any;
15+
version: string;
16+
namespace: string;
17+
nativeModuleName: string;
18+
nativeEvents?: boolean | string[];
19+
hasMultiAppSupport?: boolean;
20+
hasCustomUrlOrRegionSupport?: boolean;
21+
ModuleClass: any;
22+
}): any;
17823
export class FirebaseModule {
179-
constructor(...args: any[]);
180-
native: any;
18124
app: any;
182-
firebaseJson: any;
183-
_customUrlOrRegion: string | null;
25+
native: any;
26+
emitter: any;
27+
constructor(app: any, config: any, customUrlOrRegion?: any);
18428
}
18529
export function getFirebaseRoot(): any;
18630
}
31+

packages/app-distribution/lib/types/app-distribution.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,13 @@ export type FirebaseAppDistribution = FirebaseAppDistributionModule;
7777
export type FirebaseApp = ReactNativeFirebase.FirebaseApp & {
7878
appDistribution(): FirebaseAppDistribution;
7979
};
80+
81+
// Namespace export for backward compatibility
82+
// Using a workaround to create the namespace without circular references
83+
type _AppDistributionRelease = AppDistributionRelease;
84+
type _FirebaseAppDistributionModule = FirebaseAppDistributionModule;
85+
86+
export namespace FirebaseAppDistributionTypes {
87+
export type AppDistributionRelease = _AppDistributionRelease;
88+
export type Module = _FirebaseAppDistributionModule;
89+
}

packages/app-distribution/package.json

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
"version": "23.7.0",
44
"author": "Invertase <[email protected]> (http://invertase.io)",
55
"description": "React Native Firebase - App Distribution",
6-
"main": "lib/index.ts",
7-
"types": "lib/types.d.ts",
6+
"main": "./dist/commonjs/index.js",
7+
"module": "./dist/module/index.js",
8+
"types": "./dist/typescript/commonjs/lib/index.d.ts",
89
"scripts": {
910
"build": "genversion --esm --semi lib/version.ts",
1011
"build:clean": "rimraf android/build && rimraf ios/build",
1112
"build:plugin": "rimraf plugin/build && tsc --build plugin",
1213
"lint:plugin": "eslint plugin/src/*",
13-
"prepare": "yarn run build && yarn run build:plugin"
14+
"compile": "bob build",
15+
"prepare": "yarn run build && yarn run build:plugin && yarn compile"
1416
},
1517
"repository": {
1618
"type": "git",
@@ -28,7 +30,9 @@
2830
"expo": ">=47.0.0"
2931
},
3032
"devDependencies": {
31-
"expo": "^54.0.27"
33+
"expo": "^54.0.27",
34+
"react-native-builder-bob": "^0.40.12",
35+
"typescript": "^5.8.3"
3236
},
3337
"peerDependenciesMeta": {
3438
"expo": {
@@ -38,5 +42,53 @@
3842
"publishConfig": {
3943
"access": "public",
4044
"provenance": true
41-
}
45+
},
46+
"exports": {
47+
".": {
48+
"source": "./lib/index.ts",
49+
"import": {
50+
"types": "./dist/typescript/module/lib/index.d.ts",
51+
"default": "./dist/module/index.js"
52+
},
53+
"require": {
54+
"types": "./dist/typescript/commonjs/lib/index.d.ts",
55+
"default": "./dist/commonjs/index.js"
56+
}
57+
},
58+
"./package.json": "./package.json"
59+
},
60+
"files": [
61+
"dist",
62+
"!**/__tests__",
63+
"!**/__fixtures__",
64+
"!**/__mocks__"
65+
],
66+
"react-native-builder-bob": {
67+
"source": "lib",
68+
"output": "dist",
69+
"targets": [
70+
[
71+
"module",
72+
{
73+
"esm": true
74+
}
75+
],
76+
[
77+
"commonjs",
78+
{
79+
"esm": true
80+
}
81+
],
82+
[
83+
"typescript",
84+
{
85+
"tsc": "../../node_modules/.bin/tsc"
86+
}
87+
]
88+
]
89+
},
90+
"eslintIgnore": [
91+
"node_modules/",
92+
"dist/"
93+
]
4294
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"compilerOptions": {
3+
"allowUnreachableCode": false,
4+
"allowUnusedLabels": false,
5+
"esModuleInterop": true,
6+
"forceConsistentCasingInFileNames": true,
7+
"jsx": "react-jsx",
8+
"lib": ["ESNext", "DOM"],
9+
"module": "ESNext",
10+
"moduleResolution": "bundler",
11+
"noFallthroughCasesInSwitch": true,
12+
"noImplicitReturns": true,
13+
"noImplicitUseStrict": false,
14+
"noStrictGenericChecks": false,
15+
"noUncheckedIndexedAccess": true,
16+
"noUnusedLocals": true,
17+
"noUnusedParameters": true,
18+
"resolveJsonModule": true,
19+
"skipLibCheck": true,
20+
"strict": true,
21+
"target": "ESNext",
22+
"verbatimModuleSyntax": true,
23+
"baseUrl": ".",
24+
"rootDir": ".",
25+
"paths": {
26+
"@react-native-firebase/app": ["../app/lib"],
27+
"@react-native-firebase/app/lib/*": ["../app/lib/*"]
28+
}
29+
},
30+
"include": ["lib/**/*"],
31+
"exclude": ["node_modules", "dist", "__tests__", "**/*.test.ts"]
32+
}

0 commit comments

Comments
 (0)