From a99e275f710c6be9dfc11fc1d6c2ae94d4ec68ad Mon Sep 17 00:00:00 2001 From: sunilyadav840 Date: Thu, 26 Aug 2021 17:00:51 +0530 Subject: [PATCH] Fixed ts-strict issue of GremlinSimpleClient file --- .../GraphExplorerComponent/GremlinSimpleClient.ts | 15 ++++++++------- tsconfig.strict.json | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Explorer/Graph/GraphExplorerComponent/GremlinSimpleClient.ts b/src/Explorer/Graph/GraphExplorerComponent/GremlinSimpleClient.ts index e61f81964..3154c833f 100644 --- a/src/Explorer/Graph/GraphExplorerComponent/GremlinSimpleClient.ts +++ b/src/Explorer/Graph/GraphExplorerComponent/GremlinSimpleClient.ts @@ -12,7 +12,7 @@ export interface GremlinSimpleClientParameters { password: string; successCallback: (result: Result) => void; progressCallback: (result: Result) => void; - failureCallback: (result: Result, error: string) => void; + failureCallback: (result: Result | null, error: string) => void; infoCallback: (msg: string) => void; } @@ -62,14 +62,15 @@ export class GremlinSimpleClient { private static readonly requestChargeHeader = "x-ms-request-charge"; public params: GremlinSimpleClientParameters; - private protocols: string | string[]; - private ws: WebSocket; + private ws: WebSocket | undefined; public requestsToSend: { [requestId: string]: GremlinRequestMessage }; public pendingRequests: { [requestId: string]: GremlinRequestMessage }; constructor(params: GremlinSimpleClientParameters) { this.params = params; + this.ws = undefined; + this.pendingRequests = {}; this.requestsToSend = {}; } @@ -117,7 +118,7 @@ export class GremlinSimpleClient { } } - public decodeMessage(msg: MessageEvent): GremlinResponseMessage { + public decodeMessage(msg: MessageEvent): GremlinResponseMessage | null { if (msg.data === null) { return null; } @@ -280,7 +281,7 @@ export class GremlinSimpleClient { public static utf8ToB64(utf8Str: string) { return btoa( - encodeURIComponent(utf8Str).replace(/%([0-9A-F]{2})/g, function (match, p1) { + encodeURIComponent(utf8Str).replace(/%([0-9A-F]{2})/g, function (_match, p1) { return String.fromCharCode(parseInt(p1, 16)); }) ); @@ -305,7 +306,7 @@ export class GremlinSimpleClient { return binaryMessage; } - private onOpen(event: any) { + private onOpen(_event: any) { this.executeRequestsToSend(); } @@ -348,6 +349,6 @@ export class GremlinSimpleClient { private sendGremlinMessage(gremlinRequestMessage: GremlinRequestMessage) { const gremlinFrame = GremlinSimpleClient.buildGremlinMessage(gremlinRequestMessage); - this.ws.send(gremlinFrame); + this.ws && this.ws.send(gremlinFrame); } } diff --git a/tsconfig.strict.json b/tsconfig.strict.json index ee037db87..6edcea9cc 100644 --- a/tsconfig.strict.json +++ b/tsconfig.strict.json @@ -8,6 +8,7 @@ "noUnusedParameters": true }, "files": [ + "./src/Explorer/Graph/GraphExplorerComponent/GremlinSimpleClient.ts", "./src/AuthType.ts", "./src/Bindings/ReactBindingHandler.ts", "./src/Common/ArrayHashMap.ts", @@ -165,4 +166,4 @@ "src/Terminal/**/*", "src/Utils/arm/**/*" ] -} +} \ No newline at end of file