From e44d6ab1860b3bdd26cffe2b368f840bc56a77f6 Mon Sep 17 00:00:00 2001 From: vaidankarswapnil Date: Wed, 1 Sep 2021 15:11:03 +0530 Subject: [PATCH] Fix typescript strict issues for Toolbar and VirtualCommandBarComponent --- .../NotebookComponent/VirtualCommandBarComponent.tsx | 12 ++++++------ src/Explorer/Notebook/NotebookComponent/types.ts | 2 +- src/Explorer/Notebook/NotebookRenderer/Toolbar.tsx | 6 +++--- tsconfig.strict.json | 4 +++- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Explorer/Notebook/NotebookComponent/VirtualCommandBarComponent.tsx b/src/Explorer/Notebook/NotebookComponent/VirtualCommandBarComponent.tsx index 719e42930..05edc1a43 100644 --- a/src/Explorer/Notebook/NotebookComponent/VirtualCommandBarComponent.tsx +++ b/src/Explorer/Notebook/NotebookComponent/VirtualCommandBarComponent.tsx @@ -5,9 +5,9 @@ import { NotebookUtil } from "../NotebookUtil"; import * as NteractUtil from "../NTeractUtil"; interface VirtualCommandBarComponentProps { - kernelSpecName: string; - kernelStatus: string; - currentCellType: string; + kernelSpecName: string | undefined; + kernelStatus: string | undefined; + currentCellType: string | undefined; isNotebookUntrusted: boolean; onRender: () => void; } @@ -40,7 +40,7 @@ interface InitialProps { // Redux const makeMapStateToProps = ( - initialState: AppState, + _: AppState, initialProps: InitialProps ): ((state: AppState) => VirtualCommandBarComponentProps) => { const { contentRef } = initialProps; @@ -70,8 +70,8 @@ const makeMapStateToProps = ( currentCellType = NteractUtil.getCurrentCellType(content); return { - kernelStatus, - kernelSpecName, + kernelStatus: kernelStatus ? kernelStatus : "", + kernelSpecName: kernelSpecName ? kernelSpecName : "", currentCellType, isNotebookUntrusted: NotebookUtil.isNotebookUntrusted(state, contentRef), onRender: initialProps.onRender, diff --git a/src/Explorer/Notebook/NotebookComponent/types.ts b/src/Explorer/Notebook/NotebookComponent/types.ts index 785408208..38e83d0ab 100644 --- a/src/Explorer/Notebook/NotebookComponent/types.ts +++ b/src/Explorer/Notebook/NotebookComponent/types.ts @@ -12,7 +12,7 @@ export interface SnapshotFragment { export type SnapshotRequest = NotebookSnapshotRequest | CellSnapshotRequest; interface NotebookSnapshotRequestBase { requestId: string; - aspectRatio: number; + aspectRatio: number | undefined; notebookContentRef: string; // notebook redux contentRef downloadFilename?: string; // Optional: will download as a file } diff --git a/src/Explorer/Notebook/NotebookRenderer/Toolbar.tsx b/src/Explorer/Notebook/NotebookRenderer/Toolbar.tsx index eaa2447a6..6288b3c50 100644 --- a/src/Explorer/Notebook/NotebookRenderer/Toolbar.tsx +++ b/src/Explorer/Notebook/NotebookRenderer/Toolbar.tsx @@ -213,7 +213,7 @@ const mapDispatchToProps = ( takeNotebookSnapshot: (request: SnapshotRequest) => dispatch(cdbActions.takeNotebookSnapshot(request)), }); -const makeMapStateToProps = (state: AppState, ownProps: ComponentProps): ((state: AppState) => StateProps) => { +const makeMapStateToProps = (_: AppState, ownProps: ComponentProps): ((state: AppState) => StateProps) => { const mapStateToProps = (state: AppState) => { const cell = selectors.cell.cellFromState(state, { id: ownProps.id, contentRef: ownProps.contentRef }); const cellType = cell.cell_type; @@ -225,8 +225,8 @@ const makeMapStateToProps = (state: AppState, ownProps: ComponentProps): ((state return { cellType, - cellIdAbove, - cellIdBelow, + cellIdAbove: cellIdAbove ? cellIdAbove : "", + cellIdBelow: cellIdBelow ? cellIdBelow : "", hasCodeOutput: cellType === "code" && NotebookUtil.hasCodeCellOutput(cell as ImmutableCodeCell), isNotebookUntrusted: NotebookUtil.isNotebookUntrusted(state, ownProps.contentRef), }; diff --git a/tsconfig.strict.json b/tsconfig.strict.json index ee037db87..5ed9d2768 100644 --- a/tsconfig.strict.json +++ b/tsconfig.strict.json @@ -139,7 +139,9 @@ "./src/userContext.test.ts", "src/Common/EntityValue.tsx", "./src/Platform/Hosted/Components/SwitchAccount.tsx", - "./src/Platform/Hosted/Components/SwitchSubscription.tsx" + "./src/Platform/Hosted/Components/SwitchSubscription.tsx", + "./src/Explorer/Notebook/NotebookComponent/VirtualCommandBarComponent.tsx", + "./src/Explorer/Notebook/NotebookRenderer/Toolbar.tsx" ], "include": [ "src/CellOutputViewer/transforms/**/*",