File tree Expand file tree Collapse file tree 8 files changed +15
-14
lines changed Expand file tree Collapse file tree 8 files changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,7 @@ export class DataConnect {
198198 // @internal
199199 enableEmulator ( transportOptions : TransportOptions ) : void {
200200 if (
201+ this . _transportOptions &&
201202 this . _initialized &&
202203 ! areTransportOptionsEqual ( this . _transportOptions , transportOptions )
203204 ) {
@@ -314,7 +315,7 @@ export function validateDCOptions(dcOptions: ConnectorConfig): boolean {
314315 throw new DataConnectError ( Code . INVALID_ARGUMENT , 'DC Option Required' ) ;
315316 }
316317 fields . forEach ( field => {
317- if ( dcOptions [ field ] === null || dcOptions [ field ] === undefined ) {
318+ if ( dcOptions [ field as keyof ConnectorConfig ] === null || dcOptions [ field as keyof ConnectorConfig ] === undefined ) {
318319 throw new DataConnectError ( Code . INVALID_ARGUMENT , `${ field } Required` ) ;
319320 }
320321 } ) ;
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ export function queryRef<Data, Variables>(
125125 dataConnect : dcInstance ,
126126 refType : QUERY_STR ,
127127 name : queryName ,
128- variables
128+ variables : variables as Variables
129129 } ;
130130}
131131/**
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ import { Provider } from '@firebase/component';
2929 * Abstraction around AppCheck's token fetching capabilities.
3030 */
3131export class AppCheckTokenProvider {
32- private appCheck ?: FirebaseAppCheckInternal ;
32+ private appCheck ?: FirebaseAppCheckInternal | null ;
3333 private serverAppAppCheckToken ?: string ;
3434 constructor (
3535 app : FirebaseApp ,
@@ -47,13 +47,13 @@ export class AppCheckTokenProvider {
4747 }
4848 }
4949
50- getToken ( ) : Promise < AppCheckTokenResult > {
50+ getToken ( ) : Promise < AppCheckTokenResult | null > {
5151 if ( this . serverAppAppCheckToken ) {
5252 return Promise . resolve ( { token : this . serverAppAppCheckToken } ) ;
5353 }
5454
5555 if ( ! this . appCheck ) {
56- return new Promise < AppCheckTokenResult > ( ( resolve , reject ) => {
56+ return new Promise < AppCheckTokenResult | null > ( ( resolve , reject ) => {
5757 // Support delayed initialization of FirebaseAppCheck. This allows our
5858 // customers to initialize the RTDB SDK before initializing Firebase
5959 // AppCheck and ensures that all requests are authenticated if a token
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ export class QueryManager {
9898 addSubscription < Data , Variables > (
9999 queryRef : OperationRef < Data , Variables > ,
100100 onResultCallback : OnResultSubscription < Data , Variables > ,
101- onCompleteCallback : OnCompleteSubscription ,
101+ onCompleteCallback ? : OnCompleteSubscription ,
102102 onErrorCallback ?: OnErrorSubscription ,
103103 initialCache ?: OpResult < Data >
104104 ) : ( ) => void {
@@ -121,7 +121,7 @@ export class QueryManager {
121121 trackedQuery . subscriptions = trackedQuery . subscriptions . filter (
122122 sub => sub !== subscription
123123 ) ;
124- onCompleteCallback ( ) ;
124+ onCompleteCallback ?. ( ) ;
125125 } ;
126126 if ( initialCache && trackedQuery . currentCache !== initialCache ) {
127127 logDebug ( 'Initial cache found. Comparing dates.' ) ;
Original file line number Diff line number Diff line change @@ -56,9 +56,9 @@ export function dcFetch<T, U>(
5656 url : string ,
5757 body : DataConnectFetchBody < U > ,
5858 { signal } : AbortController ,
59- appId : string | null ,
59+ appId : string | null | undefined ,
6060 accessToken : string | null ,
61- appCheckToken : string | null ,
61+ appCheckToken : string | null | undefined ,
6262 _isUsingGen : boolean ,
6363 _callerSdkType : CallerSdkType ,
6464 _isUsingEmulator : boolean
@@ -135,7 +135,7 @@ interface MessageObject {
135135 message ?: string ;
136136}
137137function getMessage ( obj : MessageObject ) : string {
138- if ( 'message' in obj ) {
138+ if ( 'message' in obj && obj . message ) {
139139 return obj . message ;
140140 }
141141 return JSON . stringify ( obj ) ;
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ export class RESTTransport implements DataConnectTransport {
3434 private _project = 'p' ;
3535 private _serviceName : string ;
3636 private _accessToken : string | null = null ;
37- private _appCheckToken : string | null = null ;
37+ private _appCheckToken : string | null | undefined = null ;
3838 private _lastToken : string | null = null ;
3939 private _isUsingEmulator = false ;
4040 constructor (
@@ -106,7 +106,7 @@ export class RESTTransport implements DataConnectTransport {
106106 this . _accessToken = newToken ;
107107 }
108108
109- async getWithAuth ( forceToken = false ) : Promise < string > {
109+ async getWithAuth ( forceToken = false ) : Promise < string | null > {
110110 let starterPromise : Promise < string | null > = new Promise ( resolve =>
111111 resolve ( this . _accessToken )
112112 ) ;
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ export function validateArgs<Variables extends object>(
4646 let realVars : Variables ;
4747 if ( dcOrVars && 'enableEmulator' in dcOrVars ) {
4848 dcInstance = dcOrVars as DataConnect ;
49- realVars = vars ;
49+ realVars = vars as Variables ;
5050 } else {
5151 dcInstance = getDataConnect ( connectorConfig ) ;
5252 realVars = dcOrVars as Variables ;
Original file line number Diff line number Diff line change 22 "extends" : " ../../config/tsconfig.base.json" ,
33 "compilerOptions" : {
44 "outDir" : " dist" ,
5- "strict" : false
5+ "strict" : true
66 },
77 "exclude" : [" dist/**/*" , " test/**/*" ]
88}
You can’t perform that action at this time.
0 commit comments