From 5eac622b8c74ac3c3ad78b34d9e60c45205768a6 Mon Sep 17 00:00:00 2001 From: Alexis Svinartchouk Date: Tue, 14 Jul 2020 14:53:36 +0200 Subject: [PATCH] Use strict typescript compiler option Changelog-entry: Use strict typescript compiler option Change-type: patch --- .../source-selector/source-selector.tsx | 9 ++-- .../target-selector/target-selector-modal.tsx | 4 +- lib/gui/modules/child-writer.ts | 2 +- lib/shared/errors.ts | 8 ++-- npm-shrinkwrap.json | 42 +++++++++++++++++-- package.json | 3 +- tsconfig.json | 7 +--- 7 files changed, 52 insertions(+), 23 deletions(-) diff --git a/lib/gui/app/components/source-selector/source-selector.tsx b/lib/gui/app/components/source-selector/source-selector.tsx index b5053e3a..19f12ef2 100644 --- a/lib/gui/app/components/source-selector/source-selector.tsx +++ b/lib/gui/app/components/source-selector/source-selector.tsx @@ -125,10 +125,7 @@ const URLSelector = ({ cancel: () => void; }) => { const [imageURL, setImageURL] = React.useState(''); - const [recentImages, setRecentImages]: [ - URL[], - (value: React.SetStateAction) => void, - ] = React.useState([]); + const [recentImages, setRecentImages] = React.useState([]); const [loading, setLoading] = React.useState(false); React.useEffect(() => { const fetchRecentUrlImages = async () => { @@ -252,7 +249,7 @@ export class SourceSelector extends React.Component< SourceSelectorProps, SourceSelectorState > { - private unsubscribe: () => void; + private unsubscribe: (() => void) | undefined; private afterSelected: SourceSelectorProps['afterSelected']; constructor(props: SourceSelectorProps) { @@ -282,7 +279,7 @@ export class SourceSelector extends React.Component< } public componentWillUnmount() { - this.unsubscribe(); + this.unsubscribe?.(); ipcRenderer.removeListener('select-image', this.onSelectImage); } diff --git a/lib/gui/app/components/target-selector/target-selector-modal.tsx b/lib/gui/app/components/target-selector/target-selector-modal.tsx index 7c62451c..0e73bb11 100644 --- a/lib/gui/app/components/target-selector/target-selector-modal.tsx +++ b/lib/gui/app/components/target-selector/target-selector-modal.tsx @@ -161,7 +161,7 @@ export class TargetSelectorModal extends React.Component< TargetSelectorModalProps, TargetSelectorModalState > { - unsubscribe: () => void; + private unsubscribe: (() => void) | undefined; tableColumns: Array>; constructor(props: TargetSelectorModalProps) { @@ -320,7 +320,7 @@ export class TargetSelectorModal extends React.Component< } componentWillUnmount() { - this.unsubscribe(); + this.unsubscribe?.(); } render() { diff --git a/lib/gui/modules/child-writer.ts b/lib/gui/modules/child-writer.ts index 4cd5e2f9..7b14bf3b 100644 --- a/lib/gui/modules/child-writer.ts +++ b/lib/gui/modules/child-writer.ts @@ -213,7 +213,7 @@ ipc.connectTo(IPC_SERVER_ID, () => { * writer.on('fail', onFail) */ const onFail = ( - destination: sdk.sourceDestination.BlockDevice, + destination: sdk.sourceDestination.SourceDestination, error: Error, ) => { ipc.of[IPC_SERVER_ID].emit('fail', { diff --git a/lib/shared/errors.ts b/lib/shared/errors.ts index 6a07b99d..30e87172 100644 --- a/lib/shared/errors.ts +++ b/lib/shared/errors.ts @@ -17,11 +17,11 @@ import * as _ from 'lodash'; function createErrorDetails(options: { - title: string | ((error: Error) => string); - description: string | ((error: Error) => string); + title: string | ((error: Error & { path: string }) => string); + description: string; }): { - title: (error: Error) => string; - description: (error: Error) => string; + title: (error: Error & { path: string }) => string; + description: (error: Error & { path: string }) => string; } { return _.pick( _.mapValues(options, (value) => { diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 426d84b6..3b44c97c 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -5443,6 +5443,7 @@ "requires": { "anymatch": "~3.1.1", "braces": "~3.0.2", + "fsevents": "~2.1.1", "glob-parent": "~5.1.0", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", @@ -8370,6 +8371,7 @@ "udif": "^0.17.0", "unbzip2-stream": "github:balena-io-modules/unbzip2-stream#4a54f56a25b58950f9e4277c56db2912d62242e7", "unzip-stream": "^0.3.0", + "winusb-driver-generator": "^1.2.3", "xxhash": "^0.3.0", "yauzl": "^2.9.2" }, @@ -9213,6 +9215,13 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "fsevents": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", + "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "dev": true, + "optional": true + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -11887,6 +11896,7 @@ "requires": { "anymatch": "~3.1.1", "braces": "~3.0.2", + "fsevents": "~2.1.2", "glob-parent": "~5.1.0", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", @@ -15898,9 +15908,9 @@ "dev": true }, "ts-loader": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-7.0.5.tgz", - "integrity": "sha512-zXypEIT6k3oTc+OZNx/cqElrsbBtYqDknf48OZos0NQ3RTt045fBIU8RRSu+suObBzYB355aIPGOe/3kj9h7Ig==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-8.0.0.tgz", + "integrity": "sha512-giEW167rtK1V6eX/DnXEtOgcawwoIp6hqznqYNNSmraUZOq36zMhwBq12JMlYhxf50BC58bscsTSKKtE42zAuw==", "dev": true, "requires": { "chalk": "^2.3.0", @@ -16605,6 +16615,7 @@ "anymatch": "^2.0.0", "async-each": "^1.0.1", "braces": "^2.3.2", + "fsevents": "^1.2.7", "glob-parent": "^3.1.0", "inherits": "^2.0.3", "is-binary-path": "^1.0.0", @@ -16638,6 +16649,17 @@ } } }, + "fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "dev": true, + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } + }, "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", @@ -17459,6 +17481,18 @@ } } }, + "winusb-driver-generator": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/winusb-driver-generator/-/winusb-driver-generator-1.2.7.tgz", + "integrity": "sha512-NMRpH61jvvU32kGp7TcB0uzC2vxbTNpdX8kkGn4RLafycm5bKRKNzIqinnshs8G5Z7VFAMVACaCo1uPLslT3nw==", + "dev": true, + "optional": true, + "requires": { + "bindings": "^1.3.0", + "nan": "^2.14.0", + "prebuild-install": "^5.2.2" + } + }, "wordwrap": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", @@ -17882,4 +17916,4 @@ } } } -} \ No newline at end of file +} diff --git a/package.json b/package.json index e503fb39..187c0eda 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,7 @@ "node-gyp": "^7.0.0", "node-ipc": "^9.1.1", "omit-deep-lodash": "1.1.4", + "outdent": "^0.7.1", "path-is-inside": "^1.0.2", "pretty-bytes": "^5.3.0", "react": "^16.8.5", @@ -109,7 +110,7 @@ "sudo-prompt": "^9.0.0", "sys-class-rgb-led": "^2.1.0", "tmp": "^0.2.1", - "ts-loader": "^7.0.5", + "ts-loader": "^8.0.0", "ts-node": "^8.3.0", "typescript": "^3.5.3", "uuid": "^8.1.0", diff --git a/tsconfig.json b/tsconfig.json index 551a92e6..7be1e36c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,14 +1,11 @@ { "compilerOptions": { - "noImplicitAny": true, + "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, - "strictNullChecks": true, "resolveJsonModule": true, - "allowJs": true, - "moduleResolution": "node", "module": "commonjs", - "target": "es2018", + "target": "es2019", "jsx": "react", "typeRoots": ["./node_modules/@types", "./typings"], "allowSyntheticDefaultImports": true