From 7c383e8cd0f008e85c6b905a7244cc3931b0f3de Mon Sep 17 00:00:00 2001 From: Ninja3047 Date: Wed, 27 Jul 2022 21:54:10 -0400 Subject: [PATCH] fix typescript errors, add tsconfig.json --- tsconfig.json | 13 +++++++++++++ web/src/render.tsx | 12 +++++------- 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 tsconfig.json diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..662b1c9 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + "jsx": "react", + "module": "commonjs", /* Specify what module code is generated. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + /* Type Checking */ + // "strict": true, /* Enable all strict type-checking options. */ + "noImplicitAny": false, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +} diff --git a/web/src/render.tsx b/web/src/render.tsx index 4317d07..02f4b3b 100644 --- a/web/src/render.tsx +++ b/web/src/render.tsx @@ -25,15 +25,13 @@ require('highlightjs-line-numbers.js'); const FileForm = () => { const handleChange = (event: React.ChangeEvent) => { + let file = event.target.files![0]; const fr = new FileReader(); - fr.onload = (e) => { - const { result } = e.target; - if (result instanceof ArrayBuffer) { - let data = new Uint8Array(result); - encrypt_array_buffer(data); - } + fr.onload = (_e) => { + let data = new Uint8Array(fr.result as ArrayBuffer); + encrypt_array_buffer(data); } - fr.readAsArrayBuffer((event.target as HTMLInputElement).files[0]); + fr.readAsArrayBuffer(file); } return (