Skip to content

Commit 24320c4

Browse files
authored
Resolve or Replace @ts-ignore (#435)
1 parent 6301f34 commit 24320c4

File tree

4 files changed

+28
-44
lines changed

4 files changed

+28
-44
lines changed

docs/reference/modules/sdk.md

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SuspenseSubject.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export class SuspenseSubject<T> extends Subject<T> {
1010
private _innerObservable: Observable<T>;
1111
private _warmupSubscription: Subscription;
1212

13-
// @ts-ignore: TODO: double check to see if this is an RXJS thing or if we should listen to TS
13+
// @ts-expect-error: TODO: double check to see if this is an RXJS thing or if we should listen to TS
1414
private _innerSubscriber: Subscription;
15-
// @ts-ignore: TODO: double check to see if this is an RXJS thing or if we should listen to TS
15+
// @ts-expect-error: TODO: double check to see if this is an RXJS thing or if we should listen to TS
1616
private _resolveFirstEmission: () => void;
1717

1818
constructor(innerObservable: Observable<T>, private _timeoutWindow: number) {

src/firebaseApp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface FirebaseAppProviderProps {
1616
suspense?: boolean;
1717
}
1818

19-
// @ts-ignore: "__REACTFIRE_VERSION__" is replaced with actual ReactFire version (see babel.config.js)
19+
// @ts-expect-error: "__REACTFIRE_VERSION__" is replaced with actual ReactFire version (see babel.config.js)
2020
export const version = __REACTFIRE_VERSION__;
2121

2222
const shallowEq = (a: { [key: string]: any }, b: { [key: string]: any }) => a === b || [...Object.keys(a), ...Object.keys(b)].every((key) => a[key] === b[key]);

src/sdk.tsx

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,11 @@ type FirebaseSdks = Auth | Analytics | Database | Firestore | FirebasePerformanc
2525

2626
function getSdkProvider<Sdk extends FirebaseSdks>(SdkContext: React.Context<Sdk | undefined>) {
2727
return function SdkProvider(props: React.PropsWithChildren<{ sdk: Sdk }>) {
28+
if (!props.sdk) throw new Error('no sdk provided');
29+
2830
const contextualAppName = useFirebaseApp().name;
29-
let sdkAppName;
30-
31-
// @ts-ignore Auth doesn't have field 'app'
32-
if (props.sdk.app) {
33-
// @ts-ignore Auth doesn't have field 'app'
34-
sdkAppName = props.sdk.app.name;
35-
36-
// @ts-ignore only Auth has field 'name'
37-
} else if (props.sdk.name) {
38-
// @ts-ignore only Auth has field 'name'
39-
sdkAppName = props.sdk.name;
40-
}
41-
42-
if (sdkAppName !== contextualAppName) {
43-
throw new Error('sdk was initialized with a different firebase app');
44-
}
45-
46-
if (!props.sdk) {
47-
throw new Error('no sdk provided');
48-
}
31+
const sdkAppName = props?.sdk?.app?.name;
32+
if (sdkAppName !== contextualAppName) throw new Error('sdk was initialized with a different firebase app');
4933

5034
return <SdkContext.Provider value={props.sdk} {...props} />;
5135
};

0 commit comments

Comments
 (0)