From 153c5725aa1ab6c880cc94196fba99ec4267054f Mon Sep 17 00:00:00 2001 From: ChaotiCryptidz Date: Wed, 19 Jan 2022 15:33:07 +0000 Subject: [PATCH] stricter typescript --- src/ui/pages/Secrets/KeyValue/KeyValueView.tsx | 4 ++-- src/ui/pages/Settings/KeyValueEditorSettings.tsx | 2 +- src/ui/pages/Unseal.tsx | 9 +++++---- src/utils.ts | 3 ++- tsconfig.json | 2 ++ 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/ui/pages/Secrets/KeyValue/KeyValueView.tsx b/src/ui/pages/Secrets/KeyValue/KeyValueView.tsx index e2b1b15..9eaf1b4 100644 --- a/src/ui/pages/Secrets/KeyValue/KeyValueView.tsx +++ b/src/ui/pages/Secrets/KeyValue/KeyValueView.tsx @@ -29,10 +29,10 @@ export class KVSecretVew extends Component { } else { return ( <> - {Array.from(secretsMap).map((data: [string, string]) => ( + {Array.from(secretsMap).map((data: [string, unknown]) => ( - + ))} diff --git a/src/ui/pages/Settings/KeyValueEditorSettings.tsx b/src/ui/pages/Settings/KeyValueEditorSettings.tsx index 8dde414..5836b60 100644 --- a/src/ui/pages/Settings/KeyValueEditorSettings.tsx +++ b/src/ui/pages/Settings/KeyValueEditorSettings.tsx @@ -41,7 +41,7 @@ export class KeyValueEditorSettings extends Component { type="number" value={this.props.settings.kvEditorIndent} onChange={() => { - const value = this.indentInputRef.current.value; + const value = this.indentInputRef.current?.value; const indent = parseInt(value); this.props.settings.kvEditorIndent = indent; settingsSavedNotification(); diff --git a/src/ui/pages/Unseal.tsx b/src/ui/pages/Unseal.tsx index 28050d9..41e2cc4 100644 --- a/src/ui/pages/Unseal.tsx +++ b/src/ui/pages/Unseal.tsx @@ -46,6 +46,7 @@ type UnsealPageState = { mode: string; keys_submitted: number; keys_needed: number; + timer: number; }; export class Unseal extends Component { @@ -55,11 +56,10 @@ export class Unseal extends Component { mode: UnsealInputModes.FORM_INPUT, keys_submitted: 0, keys_needed: 0, + timer: 0, }; } - timer: number; - async submitKey(key: string): Promise { try { await this.props.api.submitUnsealKey(key); @@ -83,14 +83,15 @@ export class Unseal extends Component { } componentWillUnmount(): void { - clearInterval(this.timer); + clearInterval(this.state.timer); } componentDidMount(): void { this.updateStateWithSealStatus(); - this.timer = setInterval(() => { + const timer = setInterval(() => { this.updateStateWithSealStatus(); }, 500) as unknown as number; + this.setState({timer: timer}); } render(): JSX.Element { diff --git a/src/utils.ts b/src/utils.ts index e433735..c4c63ab 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -14,10 +14,11 @@ export const sortedObjectMap = (obj: Record): Map, searchValue: unknown, -): string { +): string | null { for (const key of getObjectKeys(map)) { if (map[key] === searchValue) return key; } + return null; } export function verifyJSONString(str: string): boolean { diff --git a/tsconfig.json b/tsconfig.json index 20c13d6..e17e694 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,8 +6,10 @@ "module": "es6", "target": "es2019", "strictBindCallApply": true, + "strictNullChecks": false, "noImplicitThis": true, "allowJs": true, + "strict": true, "moduleResolution": "node", "jsx": "react-jsx", "jsxImportSource": "preact",