@@ -59,7 +59,7 @@ const SUBSCRIPTION_EMMITER_TYPES = {
5959} ;
6060
6161// Exponentially-growing random delay
62- const generateInterval = k => {
62+ const generateInterval = ( k : number ) : number => {
6363 return Math . random ( ) * Math . min ( 30 , Math . pow ( 2 , k ) - 1 ) * 1000 ;
6464} ;
6565
@@ -126,13 +126,15 @@ class LiveQueryClient {
126126 emit : any ;
127127
128128 /**
129- * @param {object } options
130- * @param {string } options.applicationId - applicationId of your Parse app
131- * @param {string } options.serverURL - <b>the URL of your LiveQuery server</b>
132- * @param {string } options.javascriptKey (optional)
133- * @param {string } options.masterKey (optional) Your Parse Master Key. (Node.js only!)
134- * @param {string } options.sessionToken (optional)
135- * @param {string } options.installationId (optional)
129+ * Creates a new LiveQueryClient instance.
130+ *
131+ * @param options - Configuration options for the LiveQuery client
132+ * @param options.applicationId - The applicationId of your Parse app
133+ * @param options.serverURL - The URL of your LiveQuery server (must start with 'ws' or 'wss')
134+ * @param options.javascriptKey - (Optional) The JavaScript key for your Parse app
135+ * @param options.masterKey - (Optional) Your Parse Master Key (Node.js only!)
136+ * @param options.sessionToken - (Optional) Session token for authenticated requests
137+ * @param options.installationId - (Optional) Installation ID for the client
136138 */
137139 constructor ( {
138140 applicationId,
@@ -141,6 +143,13 @@ class LiveQueryClient {
141143 masterKey,
142144 sessionToken,
143145 installationId,
146+ } : {
147+ applicationId : string ;
148+ serverURL : string ;
149+ javascriptKey ?: string ;
150+ masterKey ?: string ;
151+ sessionToken ?: string ;
152+ installationId ?: string ;
144153 } ) {
145154 if ( ! serverURL || serverURL . indexOf ( 'ws' ) !== 0 ) {
146155 throw new Error (
@@ -165,8 +174,8 @@ class LiveQueryClient {
165174 const EventEmitter = CoreManager . getEventEmitter ( ) ;
166175 this . emitter = new EventEmitter ( ) ;
167176
168- this . on = ( eventName , listener ) => this . emitter . on ( eventName , listener ) ;
169- this . emit = ( eventName , ...args ) => this . emitter . emit ( eventName , ...args ) ;
177+ this . on = ( eventName : string , listener : ( ... args : unknown [ ] ) => void ) => this . emitter . on ( eventName , listener ) ;
178+ this . emit = ( eventName : string , ...args : unknown [ ] ) => this . emitter . emit ( eventName , ...args ) ;
170179 // adding listener so process does not crash
171180 // best practice is for developer to register their own listener
172181 this . on ( 'error' , ( ) => { } ) ;
@@ -222,7 +231,7 @@ class LiveQueryClient {
222231 . then ( ( ) => {
223232 this . socket . send ( JSON . stringify ( subscribeRequest ) ) ;
224233 } )
225- . catch ( error => {
234+ . catch ( ( error : Error ) => {
226235 subscription . subscribePromise . reject ( error ) ;
227236 } ) ;
228237
@@ -430,7 +439,7 @@ class LiveQueryClient {
430439 }
431440 case OP_EVENTS . RESULT : {
432441 if ( subscription ) {
433- const objects = data . results . map ( json => {
442+ const objects = data . results . map ( ( json : Record < string , unknown > ) => {
434443 if ( ! json . className && subscription . query ) {
435444 json . className = subscription . query . className ;
436445 }
0 commit comments