Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
6d40241
refactor(analytics): move to TypeScript
russellwheatley Aug 12, 2025
c358bcb
chore: make index.ts modular and reexport namespaced from there
russellwheatley Aug 12, 2025
135363f
chore: remove modular folder
russellwheatley Aug 12, 2025
5a58a79
chore: RN bob builder setup + package.json updates
russellwheatley Aug 12, 2025
c081c7a
tsconfig.json update to find app package
russellwheatley Aug 12, 2025
d0a837c
chore(app): validate.d.ts
russellwheatley Aug 12, 2025
068b59f
refactor: convert codebase to TypeScript
russellwheatley Aug 12, 2025
f241c17
chore: resolve index.d.ts issue
russellwheatley Aug 12, 2025
aa2a040
chore(analytics): fix types for index.ts
russellwheatley Aug 12, 2025
ffa235b
fix(analytics): RNFBAnalyticsModule make it modular export
russellwheatley Aug 12, 2025
067d333
fix: analytics with structs
russellwheatley Aug 12, 2025
bddd220
chore: remove import
russellwheatley Aug 12, 2025
e609f76
chore: rename to web types
russellwheatley Aug 12, 2025
081fb4e
fix: analytics types
russellwheatley Aug 12, 2025
86fbd14
chore: moved types to analytics types
russellwheatley Aug 12, 2025
392d882
chore: fix export types
russellwheatley Aug 13, 2025
66870da
chore: use correct type return + extend getApp()
russellwheatley Aug 13, 2025
118c892
fix: export just the type
russellwheatley Aug 13, 2025
4c52e89
use TS from root package
russellwheatley Aug 13, 2025
b4849e8
yarn.lock
russellwheatley Aug 13, 2025
82e75fd
chore: rm unneeded type
russellwheatley Aug 13, 2025
f5ac76f
test: update unit test import
russellwheatley Aug 13, 2025
81f4f36
chore: write type declaration files for web
russellwheatley Aug 13, 2025
7f4dd16
chore: move types/ dir and remove re-export of analytics
russellwheatley Aug 13, 2025
5d9901c
rm unneeded Ts declaration file
russellwheatley Aug 13, 2025
12a0c2a
fix internal types
russellwheatley Aug 13, 2025
75978c2
split modular and namespaced. import into index
russellwheatley Aug 13, 2025
24a4770
fix index.ts
russellwheatley Aug 13, 2025
e58a354
attempt at fixing type test problem
russellwheatley Aug 13, 2025
a34fa95
use default
russellwheatley Aug 13, 2025
1ab90ac
fix web api types
russellwheatley Aug 13, 2025
9d98316
fix SDK_VERSION problem
russellwheatley Aug 13, 2025
6b070ff
chore: update example app with analytics
russellwheatley Aug 13, 2025
33b9eff
tests: move tests to jest
russellwheatley Aug 19, 2025
daa4d0e
test: remove import
russellwheatley Aug 19, 2025
6c5b531
fix: types when using `analytics()` default export
russellwheatley Aug 19, 2025
0338905
chore: testing analytics types
russellwheatley Aug 19, 2025
c793a7f
Merge branch 'main' into analytics-typescript
russellwheatley Aug 19, 2025
305b17a
yarn.lock
russellwheatley Aug 19, 2025
22286d5
podfile.lock
russellwheatley Aug 19, 2025
5d1db47
chore: allow DOM types for web api
russellwheatley Aug 19, 2025
9d1f92f
chore: update example for testing
russellwheatley Aug 19, 2025
34d4765
chore: format
russellwheatley Aug 26, 2025
d00beaf
Merge branch 'main' into analytics-typescript
russellwheatley Dec 2, 2025
53a0b0b
lock files
russellwheatley Dec 2, 2025
df849a2
chore: add types.d.ts for types from app package not yet moved over
russellwheatley Dec 2, 2025
775f88a
chore: further type updates
russellwheatley Dec 2, 2025
5dafd83
fix: analytics typing
russellwheatley Dec 2, 2025
cc190b1
fix: further type updates
russellwheatley Dec 2, 2025
f2c6611
fix: tsconfig.json
russellwheatley Dec 2, 2025
bd49d05
refactor: first step to TS, package.json
russellwheatley Dec 2, 2025
e5a3672
refactor: create tsconfig.json for app package
russellwheatley Dec 2, 2025
0fdeb1e
refactor: move from JS to TS
russellwheatley Dec 2, 2025
bf7c589
refactor: further internal TS changes
russellwheatley Dec 2, 2025
7901610
refactor: internal TS implementation
russellwheatley Dec 2, 2025
0787c4a
fix: script to get version for generating versions natively
russellwheatley Dec 2, 2025
066f2d5
yarn.lock
russellwheatley Dec 2, 2025
7bd7705
fix: keep internal types internal
russellwheatley Dec 2, 2025
f9c9dc6
fix: other package TS config causing TS to output in app lib/ directory
russellwheatley Dec 3, 2025
6ec3871
fix: use types for app native module
russellwheatley Dec 3, 2025
6ffeb5e
fix: FirebaseModule types
russellwheatley Dec 3, 2025
dbbf9af
fix: FirebaseApp types
russellwheatley Dec 3, 2025
0126b84
fix: NativeModules types
russellwheatley Dec 3, 2025
d5b7c3f
fix: registry/nativeModule types
russellwheatley Dec 3, 2025
062218b
fix: update namespace types
russellwheatley Dec 3, 2025
0282cce
fix: native module types
russellwheatley Dec 3, 2025
423f30c
fix: improve native module types
russellwheatley Dec 3, 2025
34bec7b
refactor: ensure internals are on internal path
russellwheatley Dec 3, 2025
11e1e77
refactor: move to modular.ts
russellwheatley Dec 3, 2025
32e0b74
fix: remove incorrect imports
russellwheatley Dec 4, 2025
363723b
fix: metro updates to ensure compiled code is used
russellwheatley Dec 4, 2025
6b22a1f
chore: remove internal types
russellwheatley Dec 4, 2025
b3f4aae
fix: update export paths from app
russellwheatley Dec 4, 2025
a32908e
chore: fix test import
russellwheatley Dec 4, 2025
c847c2c
chore: delete index.d.ts
russellwheatley Dec 5, 2025
a2012cd
chore: remove unneeded types
russellwheatley Dec 5, 2025
36992e1
chore: remove import
russellwheatley Dec 5, 2025
5ff836a
Merge branch 'main' into analytics-typescript
russellwheatley Dec 5, 2025
8f5cae4
podfile lock
russellwheatley Dec 5, 2025
d359f0c
Merge branch 'analytics-typescript' into app-typescript
russellwheatley Dec 5, 2025
deb281d
refactor: remove types and create internal types
russellwheatley Dec 5, 2025
5c5f85d
chore: ignore dist/ for linting
russellwheatley Dec 8, 2025
2f7a5fd
chore: format
russellwheatley Dec 8, 2025
a16efca
test: fix paths in types.d.ts
russellwheatley Dec 8, 2025
488c869
Merge branch 'analytics-typescript' into app-typescript
russellwheatley Dec 8, 2025
7dcf814
chore: consice default export
russellwheatley Dec 9, 2025
89f6514
test: type exports
russellwheatley Dec 9, 2025
90866ff
chore: remove unneeded file
russellwheatley Dec 9, 2025
ca8989f
Merge branch 'main' into analytics-typescript
russellwheatley Dec 9, 2025
94290f5
yarn
russellwheatley Dec 9, 2025
b6dcbb0
Merge branch 'analytics-typescript' into app-typescript
russellwheatley Dec 9, 2025
23949ac
Merge app-typescript excluding analytics package changes
russellwheatley Dec 9, 2025
e24dd5a
fix: null serialization issues
russellwheatley Dec 9, 2025
c5e8b3b
yarn.lock
russellwheatley Dec 9, 2025
7876186
chore: update TS packages with correct paths
russellwheatley Dec 9, 2025
0517e5d
fix: export FirebaseApp from app package
russellwheatley Dec 9, 2025
8f31bad
refactor: rename type file to "app" and remove imports from namespaced
russellwheatley Dec 9, 2025
3a609b4
refactor: exporting types
russellwheatley Dec 9, 2025
d9a5570
test: mock analytics functions
russellwheatley Dec 9, 2025
3643dff
test: update jest mocks
russellwheatley Dec 9, 2025
d7597ae
test: more jest setup
russellwheatley Dec 9, 2025
4d5e487
refactor: update app types and import/exports
russellwheatley Dec 9, 2025
94c0778
fix: firebase app types
russellwheatley Dec 9, 2025
19ca9d9
test: fix firestore mocks
russellwheatley Dec 10, 2025
1c8bab0
test: update jest.setup with more mocks
russellwheatley Dec 10, 2025
b6f7739
test(database) fix broken mocks
russellwheatley Dec 10, 2025
8aed023
test: jest cleanup
russellwheatley Dec 10, 2025
bf7d55d
chore: further type updates
russellwheatley Dec 10, 2025
ca25dae
chore: format
russellwheatley Dec 10, 2025
1d27232
fix: bring logic back
russellwheatley Dec 10, 2025
75b14c9
refactor: app web JS files to TS files
russellwheatley Dec 10, 2025
54c6fdc
fix: remove unused directive
russellwheatley Dec 10, 2025
e02db2c
refactor: move to types/ directory
russellwheatley Dec 10, 2025
882be8f
chore: remove redundant declaration files
russellwheatley Dec 11, 2025
4eeec93
chore: remove any type
russellwheatley Dec 11, 2025
d9c8b50
chore: document ts error expected for modular deprecation argument
russellwheatley Dec 11, 2025
8a449f3
chore: type improvements
russellwheatley Dec 11, 2025
b881541
chore: remove unneeded exports
russellwheatley Dec 11, 2025
80cb0f5
fix: test-types for app
russellwheatley Dec 11, 2025
5e459c1
fix: use root like previous for type-test
russellwheatley Dec 11, 2025
1179673
chore: reinstate type-test for functions
russellwheatley Dec 11, 2025
2045bee
refactor: remove types.d.ts file from functions
russellwheatley Dec 11, 2025
651a385
test: update jest TS config
russellwheatley Dec 11, 2025
2d0c3a9
refactor(functions): in light of app package refactor
russellwheatley Dec 11, 2025
664b335
fix(functions): types for type-test
russellwheatley Dec 11, 2025
458d30f
refactor: functions types to remove duplication
russellwheatley Dec 11, 2025
e26cf1e
fix: type tests were not working, fixed for functions
russellwheatley Dec 12, 2025
fcacd26
test: update app test types
russellwheatley Dec 12, 2025
78c92ae
test: include app type test
russellwheatley Dec 12, 2025
6d2c295
test: update root tsconfig.json for jest tests
russellwheatley Dec 12, 2025
4825442
fix: remove globals
russellwheatley Dec 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ export default [
'**/type-test.ts',
'packages/**/modular/dist/**/*',
'packages/ai/__tests__/test-utils',
'packages/**/dist/**/*',
'packages/vertexai/__tests__/test-utils',
'packages/vertexai/dist',
'packages/ai/dist',
],
},
...compat
Expand Down
342 changes: 335 additions & 7 deletions jest.setup.ts

Large diffs are not rendered by default.

21 changes: 15 additions & 6 deletions packages/ai/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react-jsx",
"lib": [
"ESNext"
],
"lib": ["ESNext"],
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "Bundler",
Expand All @@ -24,9 +22,20 @@
"strict": true,
"baseUrl": ".",
"paths": {
"@react-native-firebase/app": ["../app/lib"],
"@react-native-firebase/app/lib/common/*": ["../app/dist/typescript/commonjs/lib/common/*"],
"@react-native-firebase/app/lib/common": ["../app/dist/typescript/commonjs/lib/common"],
"@react-native-firebase/app/lib/internal/web/*": [
"../app/dist/typescript/commonjs/lib/internal/web/*"
],
"@react-native-firebase/app/lib/internal/*": [
"../app/dist/typescript/commonjs/lib/internal/*"
],
"@react-native-firebase/app/lib/internal": ["../app/dist/typescript/commonjs/lib/internal"],
"@react-native-firebase/app": ["../app/dist/typescript/commonjs/lib"],
"@react-native-firebase/auth": ["../auth/lib"],
"@react-native-firebase/app-check": ["../app-check/lib"],
"@react-native-firebase/app-check": ["../app-check/lib"]
}
}
},
"include": ["lib/**/*"],
"exclude": ["node_modules", "dist", "__tests__", "**/*.test.ts"]
}
43 changes: 31 additions & 12 deletions packages/app/lib/FirebaseApp.js → packages/app/lib/FirebaseApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,26 @@
* limitations under the License.
*
*/
import { warnIfNotModularCall } from '@react-native-firebase/app/lib/common';
import { warnIfNotModularCall } from './common';
import { getAppModule } from './internal/registry/nativeModule';
import type { ReactNativeFirebase, Utils } from './types/app';

export default class FirebaseApp {
constructor(options, appConfig, fromNative, deleteApp) {
const { name, automaticDataCollectionEnabled } = appConfig;
export default class FirebaseApp implements ReactNativeFirebase.FirebaseAppBase {
private _name: string;
private _deleted: boolean;
private _deleteApp: () => Promise<void>;
private _options: ReactNativeFirebase.FirebaseAppOptions;
private _automaticDataCollectionEnabled: boolean;
_initialized: boolean;
_nativeInitialized: boolean;

constructor(
options: ReactNativeFirebase.FirebaseAppOptions,
appConfig: ReactNativeFirebase.FirebaseAppConfig,
fromNative: boolean,
deleteApp: () => Promise<void>,
) {
const { name = '[DEFAULT]', automaticDataCollectionEnabled } = appConfig;

this._name = name;
this._deleted = false;
Expand All @@ -36,44 +50,49 @@ export default class FirebaseApp {
}
}

get name() {
get name(): string {
return this._name;
}

get options() {
get options(): ReactNativeFirebase.FirebaseAppOptions {
return Object.assign({}, this._options);
}

get automaticDataCollectionEnabled() {
get automaticDataCollectionEnabled(): boolean {
return this._automaticDataCollectionEnabled;
}

set automaticDataCollectionEnabled(enabled) {
set automaticDataCollectionEnabled(enabled: boolean) {
this._checkDestroyed();
getAppModule().setAutomaticDataCollectionEnabled(this.name, enabled);
this._automaticDataCollectionEnabled = enabled;
}

_checkDestroyed() {
private _checkDestroyed(): void {
if (this._deleted) {
throw new Error(`Firebase App named '${this._name}' already deleted`);
}
}

extendApp(extendedProps) {
extendApp(extendedProps: Record<string, unknown>): void {
warnIfNotModularCall(arguments);
this._checkDestroyed();
Object.assign(this, extendedProps);
}

delete() {
delete(): Promise<void> {
warnIfNotModularCall(arguments, 'deleteApp()');
this._checkDestroyed();
return this._deleteApp();
}

toString() {
toString(): string {
warnIfNotModularCall(arguments, '.name property');
return this.name;
}

// For backward compatibility - utils method added by registry
utils(): Utils.Module {
throw new Error('utils() should be added by registry');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*
*/

// @ts-expect-error - No type declarations available
import binaryToBase64 from 'react-native/Libraries/Utilities/binaryToBase64';
import { promiseDefer } from './promise';

Expand All @@ -23,7 +24,7 @@ const CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
/**
* window.btoa
*/
function btoa(input) {
function btoa(input: string): string {
let map;
let i = 0;
let block = 0;
Expand Down Expand Up @@ -51,11 +52,11 @@ function btoa(input) {
/**
* window.atob
*/
function atob(input) {
function atob(input: string): string {
let i = 0;
let bc = 0;
let bs = 0;
let buffer;
let buffer: number | string;
let output = '';

const str = input.replace(/[=]+$/, '');
Expand All @@ -69,7 +70,7 @@ function atob(input) {
for (
bc = 0, bs = 0, i = 0;
(buffer = str.charAt(i++));
~buffer && ((bs = bc % 4 ? bs * 64 + buffer : buffer), bc++ % 4)
~buffer && ((bs = bc % 4 ? bs * 64 + (buffer as number) : buffer), bc++ % 4)
? (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6))))
: 0
) {
Expand All @@ -79,23 +80,30 @@ function atob(input) {
return output;
}

export interface Base64Result {
string: string | ArrayBuffer | null;
format: 'data_url' | 'base64';
}

/**
* Converts a Blob, ArrayBuffer or Uint8Array to a base64 string.
*/
function fromData(data) {
function fromData(data: Blob | ArrayBuffer | Uint8Array): Promise<Base64Result> {
if (data instanceof Blob) {
const fileReader = new FileReader();
const { resolve, reject, promise } = promiseDefer();
const { resolve, reject, promise } = promiseDefer<Base64Result>();

fileReader.readAsDataURL(data);

fileReader.onloadend = function onloadend() {
resolve({ string: fileReader.result, format: 'data_url' });
fileReader.onloadend = () => {
if (fileReader?.result) {
resolve?.({ string: fileReader.result, format: 'data_url' });
}
};

fileReader.onerror = function onerror(event) {
fileReader.abort();
reject(event);
fileReader.onerror = event => {
fileReader?.abort();
reject?.(event);
};

return promise;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
import { deepGet, deepSet } from './deeps';

export default class MutatableParams {
constructor(parentInstance) {
_mutatableParams: Record<string, unknown>;
_parentInstance: MutatableParams;

constructor(parentInstance?: MutatableParams) {
if (parentInstance) {
this._mutatableParams = parentInstance._mutatableParams;
this._parentInstance = parentInstance;
Expand All @@ -28,20 +31,20 @@ export default class MutatableParams {
}
}

set(param, value) {
set(param: string, value: unknown): MutatableParams {
deepSet(this._mutatableParams, param, value);
return this._parentInstance;
}

get(param) {
return deepGet(this._mutatableParams, param, '.');
get<T = unknown>(param: string): T | undefined {
return deepGet<T>(this._mutatableParams, param, '.');
}

toJSON() {
toJSON(): Record<string, unknown> {
return Object.assign({}, this._mutatableParams);
}

validate() {
validate(): void {
// do nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
*/

export default class ReferenceBase {
constructor(_path) {
path: string;

constructor(_path: string) {
let path = _path;

if (path) {
Expand All @@ -37,7 +39,7 @@ export default class ReferenceBase {
* @type {String}
* {@link https://firebase.google.com/docs/reference/js/firebase.database.Reference#key}
*/
get key() {
get key(): string | null {
return this.path === '/' ? null : this.path.substring(this.path.lastIndexOf('/') + 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,29 @@ import { isArray, isObject } from './validate';
* @param joiner
* @returns {*}
*/
export function deepGet(object, path, joiner = '/') {
export function deepGet<T = unknown>(
object: Record<string, unknown> | unknown[],
path: string,
joiner: string = '/',
): T | undefined {
if (!isObject(object) && !Array.isArray(object)) {
return undefined;
}
const keys = path.split(joiner);

let i = 0;
let tmp = object;
let tmp: unknown = object;
const len = keys.length;

while (i < len) {
const key = keys[i++];
const key = keys[i++]!;
if (!tmp || !Object.hasOwnProperty.call(tmp, key)) {
return undefined;
}
tmp = tmp[key];
tmp = (tmp as Record<string, unknown>)[key];
}

return tmp;
return tmp as T;
}

/**
Expand All @@ -54,26 +58,32 @@ export function deepGet(object, path, joiner = '/') {
* @param initPaths
* @param joiner
*/
export function deepSet(object, path, value, initPaths = true, joiner = '.') {
export function deepSet(
object: Record<string, unknown>,
path: string,
value: unknown,
initPaths: boolean = true,
joiner: string = '.',
): boolean {
if (!isObject(object)) {
return false;
}
const keys = path.split(joiner);

let i = 0;
let _object = object;
let _object: unknown = object;
const len = keys.length - 1;

while (i < len) {
const key = keys[i++];
const key = keys[i++]!;
if (initPaths && !Object.hasOwnProperty.call(object, key)) {
_object[key] = {};
(_object as Record<string, unknown>)[key] = {};
}
_object = _object[key];
_object = (_object as Record<string, unknown>)[key];
}

if (isObject(_object) || (isArray(_object) && !Number.isNaN(keys[i]))) {
_object[keys[i]] = value;
(_object as Record<string, unknown>)[keys[i]!] = value;
} else {
return false;
}
Expand Down
Loading
Loading