From 103b3bf6c91715e9e32a962c810fc72d5add002e Mon Sep 17 00:00:00 2001 From: Sunil Kumar Yadav <79906609+sunilyadav840@users.noreply.github.com> Date: Thu, 15 Jul 2021 11:21:36 +0530 Subject: [PATCH] fixed typescript strict of CqlUtilities.test.ts CapabilityUtils.ts file (#787) Co-authored-by: Steve Faulkner --- src/Explorer/Tables/CqlUtilities.ts | 3 ++- src/Utils/CapabilityUtils.ts | 9 +++++++-- tsconfig.strict.json | 13 +++++++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Explorer/Tables/CqlUtilities.ts b/src/Explorer/Tables/CqlUtilities.ts index 52decfef0..73a0b4c35 100644 --- a/src/Explorer/Tables/CqlUtilities.ts +++ b/src/Explorer/Tables/CqlUtilities.ts @@ -1,4 +1,5 @@ -export function getQuotedCqlIdentifier(identifier: string): string { +// Added return type optional undefined because passing undefined from test cases. +export function getQuotedCqlIdentifier(identifier: string | undefined): string | undefined { let result = identifier; if (!identifier) { return result; diff --git a/src/Utils/CapabilityUtils.ts b/src/Utils/CapabilityUtils.ts index 040766219..fc2de8149 100644 --- a/src/Utils/CapabilityUtils.ts +++ b/src/Utils/CapabilityUtils.ts @@ -1,7 +1,12 @@ import * as Constants from "../Common/Constants"; import { userContext } from "../UserContext"; -export const isCapabilityEnabled = (capabilityName: string): boolean => - userContext.databaseAccount?.properties?.capabilities?.some((capability) => capability.name === capabilityName); +export const isCapabilityEnabled = (capabilityName: string): boolean => { + const { databaseAccount } = userContext; + if (databaseAccount && databaseAccount.properties && databaseAccount.properties.capabilities) { + return databaseAccount.properties.capabilities.some((capability) => capability.name === capabilityName); + } + return false; +}; export const isServerlessAccount = (): boolean => isCapabilityEnabled(Constants.CapabilityNames.EnableServerless); diff --git a/tsconfig.strict.json b/tsconfig.strict.json index 4b569ef59..a385c5b7d 100644 --- a/tsconfig.strict.json +++ b/tsconfig.strict.json @@ -8,9 +8,6 @@ "noUnusedParameters": true }, "files": [ - "./src/Explorer/Notebook/SchemaAnalyzer/SchemaAnalyzerSplashScreen.tsx", - "./src/Explorer/Panes/PanelContainerComponent.tsx", - "./src/hooks/useSidePanel.ts", "./src/AuthType.ts", "./src/Bindings/ReactBindingHandler.ts", "./src/Common/ArrayHashMap.ts", @@ -68,12 +65,16 @@ "./src/Explorer/Notebook/SchemaAnalyzer/SchemaAnalyzerUtils.ts", "./src/Explorer/OpenFullScreen.test.tsx", "./src/Explorer/OpenFullScreen.tsx", + "./src/Explorer/Panes/PanelContainerComponent.test.tsx", + "./src/Explorer/Panes/PanelContainerComponent.tsx", "./src/Explorer/Panes/PanelFooterComponent.tsx", "./src/Explorer/Panes/PanelInfoErrorComponent.tsx", "./src/Explorer/Panes/PanelLoadingScreen.tsx", + "./src/Explorer/Panes/PanelStyles.ts", "./src/Explorer/Panes/Tables/Validators/EntityPropertyNameValidator.ts", "./src/Explorer/Panes/Tables/Validators/EntityPropertyValidationCommon.ts", "./src/Explorer/Tables/Constants.ts", + "./src/Explorer/Tables/CqlUtilities.test.ts", "./src/Explorer/Tables/CqlUtilities.ts", "./src/Explorer/Tables/DataTable/CacheBase.ts", "./src/Explorer/Tables/Entities.ts", @@ -96,7 +97,9 @@ "./src/Shared/Constants.ts", "./src/Shared/DefaultExperienceUtility.ts", "./src/Shared/ExplorerSettings.ts", + "./src/Shared/LocalStorageUtility.ts", "./src/Shared/PriceEstimateCalculator.ts", + "./src/Shared/SessionStorageUtility.ts", "./src/Shared/StorageUtility.test.ts", "./src/Shared/StorageUtility.ts", "./src/Shared/StringUtility.test.ts", @@ -108,6 +111,8 @@ "./src/Utils/Base64Utils.test.ts", "./src/Utils/Base64Utils.ts", "./src/Utils/BlobUtils.ts", + "./src/Utils/CapabilityUtils.ts", + "./src/Utils/CloudUtils.ts", "./src/Utils/GitHubUtils.test.ts", "./src/Utils/GitHubUtils.ts", "./src/Utils/MessageValidation.test.ts", @@ -155,4 +160,4 @@ "src/Terminal/**/*", "src/Utils/arm/**/*" ] -} \ No newline at end of file +}