diff --git a/desktop/package.json b/desktop/package.json index 66d0659370..de6199f788 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -39,6 +39,7 @@ "promise-fs": "^2.1.1" }, "devDependencies": { + "@tsconfig/node18": "^18.2.2", "@types/auto-launch": "^5.0.2", "@types/ffmpeg-static": "^3.0.1", "@types/get-folder-size": "^2.0.0", diff --git a/desktop/src/preload.ts b/desktop/src/preload.ts index fb8dd1f9b6..f39dae0986 100644 --- a/desktop/src/preload.ts +++ b/desktop/src/preload.ts @@ -1,14 +1,16 @@ /** * @file The preload script * - * The preload script runs in an isolated environment. It has access to some of - * the Node imports. Its task is to expose these imports and other functions as - * an object on the DOM, so that the renderer process can invoke functions that - * live in the main (Node.js) process. + * The preload script runs in a renderer process before its web contents begin + * loading. During their execution they have access to a subset of Node.js APIs + * and imports. Its purpose is to expose the relevant imports and other + * functions as an object on the DOM, so that the renderer process can invoke + * functions that live in the main (Node.js) process if needed. * - * Note that this script cannot import other code from `src/` - this runs in a - * separate, third, process (a BrowserWindow context that runs prior to the - * renderer process). + * Note that this script cannot import other code from `src/` - conceptually it + * can be thought of as running in a separate, third, process different from + * both the main or a renderer process (technically, it runs in a BrowserWindow + * context that runs prior to the renderer process). * * That said, this can be split into multiple files if we wished. However, * that'd require us setting up a bundler to package it back up into a single JS diff --git a/desktop/tsconfig.json b/desktop/tsconfig.json index 142c36005c..a4d99a9abd 100644 --- a/desktop/tsconfig.json +++ b/desktop/tsconfig.json @@ -1,17 +1,51 @@ { + /* TSConfig for a set of vanilla TypeScript files that need to be transpiled + into JavaScript that'll then be loaded and run by the main (node) process + of our Electron app. */ + + /* TSConfig docs: https://aka.ms/tsconfig.json */ + + /* Recommended target, lib and other settings for code running in the + version of Node.js bundled with Electron. + + Currently, with Electron 25, this is Node.js 18 + https://www.electronjs.org/blog/electron-25-0 + */ + // "extends": "@tsconfig/node18/tsconfig.json", "compilerOptions": { + /* Emit the generated JS into `app/` */ + "outDir": "app", + /* Generate source maps */ + "sourceMap": true, + /* Allow absolute imports starting with src as root */ + "baseUrl": "src", + /* Allow imports of paths in node_modules */ + "paths": { + "*": ["node_modules/*"] + }, + + /* Temporary overrides to get things to compile with the older config */ "target": "es2021", "module": "commonjs", "esModuleInterop": true, - /* Emit the generated JS into app */ - "outDir": "app", - "noImplicitAny": true, - "sourceMap": true, - "baseUrl": "src", - "paths": { - "*": ["node_modules/*"] - } + "strict": false, + "noImplicitAny": true + + /* Below is the state we want */ + /* Enable these one by one */ + + /* Require the `type` modifier when importing types */ + // "verbatimModuleSyntax": true + + /* Stricter than strict */ + // "noImplicitReturns": true, + // "noUnusedParameters": true, + // "noUnusedLocals": true, + // "noFallthroughCasesInSwitch": true, + /* e.g. makes array indexing returns undefined */ + // "noUncheckedIndexedAccess": true, + // "exactOptionalPropertyTypes": true, }, - /* Transpile all ts files in src/ */ + /* Transpile all `.ts` files in `src/` */ "include": ["src/**/*.ts"] } diff --git a/desktop/yarn.lock b/desktop/yarn.lock index b7e185424b..1b6a831916 100644 --- a/desktop/yarn.lock +++ b/desktop/yarn.lock @@ -205,6 +205,11 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf" integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== +"@tsconfig/node18@^18.2.2": + version "18.2.2" + resolved "https://registry.yarnpkg.com/@tsconfig/node18/-/node18-18.2.2.tgz#81fb16ecff0d400b1cbadbf76713b50f331029ce" + integrity sha512-d6McJeGsuoRlwWZmVIeE8CUA27lu6jLjvv1JzqmpsytOYYbVi1tHZEnwCNVOXnj4pyLvneZlFlpXUK+X9wBWyw== + "@types/auto-launch@^5.0.2": version "5.0.2" resolved "https://registry.yarnpkg.com/@types/auto-launch/-/auto-launch-5.0.2.tgz#4970f01e5dd27572489b7fe77590204a19f86bd0"