Forráskód Böngészése

Settle on a tsconfig for now

Electron also comes with its own type definitions, and from a (possibly dated)
blog post announcing this I got that we should not be overriding it with
@types/node: https://www.electronjs.org/pt/blog/typescript
Manav Rathi 1 éve
szülő
commit
a0f95b6080
3 módosított fájl, 40 hozzáadás és 23 törlés
  1. 0 2
      desktop/package.json
  2. 40 11
      desktop/tsconfig.json
  3. 0 10
      desktop/yarn.lock

+ 0 - 2
desktop/package.json

@@ -39,11 +39,9 @@
         "promise-fs": "^2.1.1"
         "promise-fs": "^2.1.1"
     },
     },
     "devDependencies": {
     "devDependencies": {
-        "@tsconfig/node18": "^18.2.2",
         "@types/auto-launch": "^5.0.2",
         "@types/auto-launch": "^5.0.2",
         "@types/ffmpeg-static": "^3.0.1",
         "@types/ffmpeg-static": "^3.0.1",
         "@types/get-folder-size": "^2.0.0",
         "@types/get-folder-size": "^2.0.0",
-        "@types/node": "18.15.0",
         "@types/node-fetch": "^2.6.2",
         "@types/node-fetch": "^2.6.2",
         "@types/promise-fs": "^2.1.1",
         "@types/promise-fs": "^2.1.1",
         "@typescript-eslint/eslint-plugin": "^5.28.0",
         "@typescript-eslint/eslint-plugin": "^5.28.0",

+ 40 - 11
desktop/tsconfig.json

@@ -5,34 +5,63 @@
 
 
     /* TSConfig docs: https://aka.ms/tsconfig.json */
     /* 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": {
     "compilerOptions": {
+        /* 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
+
+           Note that we cannot do
+
+               "extends": "@tsconfig/node18/tsconfig.json",
+
+           because that sets "lib": ["es2023"]. However (and I don't fully
+           understand what's going on here), that breaks our compilation since
+           tsc can then not find type definitions of things like ReadableStream.
+
+           Adding "dom" to "lib" (e.g. `"lib": ["es2023", "dom"]`) fixes the
+           issue, but that doesn't sound correct - the main Electron process
+           isn't running in a browser context.
+
+           It is possible that we're using some of the types incorrectly. For
+           now, we just omit the "lib" definition and rely on the defaults for
+           the "target" we've chosen. This is also what the current
+           electron-forge starter does:
+
+               yarn create electron-app electron-forge-starter -- --template=webpack-typescript
+
+           Enhancement: Can revisit this later.
+
+           Refs:
+           - https://github.com/electron/electron/issues/27092
+           - https://github.com/electron/electron/issues/16146
+        */
+
+        "target": "es2022",
+        "module": "node16",
+
+        "esModuleInterop": true,
+        "skipLibCheck": true,
+
         /* Emit the generated JS into `app/` */
         /* Emit the generated JS into `app/` */
         "outDir": "app",
         "outDir": "app",
         /* Generate source maps */
         /* Generate source maps */
         "sourceMap": true,
         "sourceMap": true,
         /* Allow absolute imports starting with src as root */
         /* Allow absolute imports starting with src as root */
         "baseUrl": "src",
         "baseUrl": "src",
-        /* Allow imports of paths in node_modules */
+        /* Allow imports of paths from node_modules */
         "paths": {
         "paths": {
             "*": ["node_modules/*"]
             "*": ["node_modules/*"]
         },
         },
 
 
         /* Temporary overrides to get things to compile with the older config */
         /* Temporary overrides to get things to compile with the older config */
-        "target": "es2021",
-        "module": "commonjs",
-        "esModuleInterop": true,
         "strict": false,
         "strict": false,
         "noImplicitAny": true
         "noImplicitAny": true
 
 
         /* Below is the state we want */
         /* Below is the state we want */
         /* Enable these one by one */
         /* Enable these one by one */
+        // "strict": true,
 
 
         /* Require the `type` modifier when importing types */
         /* Require the `type` modifier when importing types */
         // "verbatimModuleSyntax": true
         // "verbatimModuleSyntax": true

+ 0 - 10
desktop/yarn.lock

@@ -205,11 +205,6 @@
   resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
   resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
   integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==
   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":
 "@types/auto-launch@^5.0.2":
   version "5.0.2"
   version "5.0.2"
   resolved "https://registry.yarnpkg.com/@types/auto-launch/-/auto-launch-5.0.2.tgz#4970f01e5dd27572489b7fe77590204a19f86bd0"
   resolved "https://registry.yarnpkg.com/@types/auto-launch/-/auto-launch-5.0.2.tgz#4970f01e5dd27572489b7fe77590204a19f86bd0"
@@ -284,11 +279,6 @@
   resolved "https://registry.yarnpkg.com/@types/node/-/node-18.0.3.tgz#463fc47f13ec0688a33aec75d078a0541a447199"
   resolved "https://registry.yarnpkg.com/@types/node/-/node-18.0.3.tgz#463fc47f13ec0688a33aec75d078a0541a447199"
   integrity sha512-HzNRZtp4eepNitP+BD6k2L6DROIDG4Q0fm4x+dwfsr6LGmROENnok75VGw40628xf+iR24WeMFcHuuBDUAzzsQ==
   integrity sha512-HzNRZtp4eepNitP+BD6k2L6DROIDG4Q0fm4x+dwfsr6LGmROENnok75VGw40628xf+iR24WeMFcHuuBDUAzzsQ==
 
 
-"@types/node@18.15.0":
-  version "18.15.0"
-  resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.0.tgz#286a65e3fdffd691e170541e6ecb0410b16a38be"
-  integrity sha512-z6nr0TTEOBGkzLGmbypWOGnpSpSIBorEhC4L+4HeQ2iezKCi4f77kyslRwvHeNitymGQ+oFyIWGP96l/DPSV9w==
-
 "@types/node@^10.0.3":
 "@types/node@^10.0.3":
   version "10.17.60"
   version "10.17.60"
   resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b"
   resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b"