electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.68k stars 1.74k forks source link

tsc fails to compile electron builder #7837

Closed MadEddieFFS closed 11 months ago

MadEddieFFS commented 1 year ago

When running tsc within my Electron folder I receive the following errors:

╰─ tsc
node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property '"accept-charset"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property '"accept-encoding"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property '"accept-language"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property '"content-length"' of type 'string | number' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property '"proxy-authenticate"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property '"sec-websocket-extensions"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property '"sec-websocket-protocol"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property '"set-cookie"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property '"www-authenticate"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property 'accept' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property 'connection' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property 'cookie' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property 'dav' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property 'link' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property 'prgama' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9:5 - error TS2411: Property 'via' of type 'string | string[]' is not assignable to 'string' index type 'string'.

9     [key: string]: string;
      ~~~~~~~~~~~~~~~~~~~~~~

Found 16 errors in the same file, starting at: node_modules/electron-updater/node_modules/builder-util-runtime/out/httpExecutor.d.ts:9

I do have a .yarnrc.yml file with

nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.6.4.cjs

By Adding SkipLibCheck to my tsconfig I can compile fine but this is not good practice

mmaietta commented 1 year ago

Please try latest pre-release https://github.com/electron-userland/electron-builder/releases/tag/v24.8.1

It has the updated @node/types

LocutusOfPenguin commented 1 year ago

I have the same problem. Updating to 24.8.1 doesn't help.

mmaietta commented 1 year ago

Can you please create a sample reproducible repo with electron-quick-start or similar so that I can debug this locally? That'd help immensely

si458 commented 11 months ago

im having the same issue here, ive even tried updating to latest 24.9.1 my steps:

  1. setup a basic ionic app (dont add ios/android platforms)
  2. ionic build
  3. npm i @capacitor-community/electron
  4. npx cap add @capacitor-community/electron
  5. cd electron
  6. npm run electron:pack

EDIT: LOGS BELOW FROM UPDATED 24.9.1 OF ELECTRON-BUILDER

PS C:\Users\ASUS\Documents\Developer\MySumUp\electron> npm run electron:pack

> mysumup@1.0.0 electron:pack
> npm run build && electron-builder build --dir -c ./electron-builder.config.json

> mysumup@1.0.0 build
> tsc && electron-rebuild

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property '"accept-charset"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property '"accept-encoding"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property '"accept-language"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property '"content-length"' of type 'string | number' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property '"proxy-authenticate"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property '"sec-websocket-extensions"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property '"sec-websocket-protocol"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property '"set-cookie"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property '"www-authenticate"' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property 'accept' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property 'connection' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property 'cookie' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property 'dav' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property 'link' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property 'prgama' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

node_modules/builder-util-runtime/out/httpExecutor.d.ts:13:5 - error TS2411: Property 'via' of type 'string | string[]' is not assignable to 'string' index type 'string'.

13     [key: string]: string;
       ~~~~~~~~~~~~~~~~~~~~~~

Found 16 errors in the same file, starting at: node_modules/builder-util-runtime/out/httpExecutor.d.ts:13
LocutusOfPenguin commented 11 months ago

i have the same 16 errors. For my part im doing this with "framework7 create", Capacitor project, Cordova and then https://capacitor-community.github.io/electron/docs/gettingstarted/ Lateron run inside electron folder: npm run electron:pack This prints out all these errors.

Including: Updating all electron packages in electron folder to LATEST doesn't help.

package.json now (after UPDATE) looks like this: { "name": "My App", "version": "1.0.0", "description": "An Amazing Capacitor App", "author": { "name": "", "email": "" }, "repository": { "type": "git", "url": "" }, "license": "MIT", "main": "build/src/index.js", "scripts": { "build": "tsc && electron-rebuild", "electron:start-live": "node ./live-runner.js", "electron:start": "npm run build && electron --inspect=5858 ./", "electron:pack": "npm run build && electron-builder build --dir -c ./electron-builder.config.json", "electron:make": "npm run build && electron-builder build -c ./electron-builder.config.json -p always" }, "dependencies": { "@capacitor-community/electron": "^5.0.0", "chokidar": "~3.5.3", "electron-is-dev": "~2.0.0", "electron-serve": "~1.1.0", "electron-unhandled": "~4.0.1", "electron-updater": "^5.3.0", "electron-window-state": "^5.0.3" }, "devDependencies": { "electron": "^27.1.0", "electron-builder": "^24.6.4", "electron-rebuild": "^3.2.9", "typescript": "^5.3.2" }, "keywords": [ "capacitor", "electron" ] }

si458 commented 11 months ago

glad its not just me! just created a new app, first time learning, wanna show it off in exe/installer form, cant even pack, doh!

mmaietta commented 11 months ago

@LocutusOfPenguin your version for "electron-builder": "^24.6.4", is not correct. It needs to be pinned to 24.8.1. Please verify that it is correct in your yarn.lock or package-lock.json.

Again, the code [key: string]: string; is nowhere in that file anymore, so if you're still receiving an error, either add a gist or sample repo where I can debug further. As it currently stands, we use updated @types/node and the updated code is the following below https://github.com/electron-userland/electron-builder/blob/6b84010b67de0ddc07404d53436bbfbfa2761f88/packages/builder-util-runtime/src/httpExecutor.ts#L14-L16

MadEddieFFS commented 11 months ago

Just a note that I previously found that npm wasn't handling these dependent packages well and I would urge people to try yarn.

si458 commented 11 months ago

@mmaietta so what version of electron-builder should we be using which should include the fix? I'll try my setup again soon

si458 commented 11 months ago

@mmaietta i fixed my issued! a new version of electron-updater isnt set as the latest in npm! so you have to force install the latest version npm install electron-updater@6.1.7 https://www.npmjs.com/package/electron-updater?activeTab=versions - its showing as next not latest

LocutusOfPenguin commented 11 months ago

yes. for me same. Errors gone with new version! My webstorm not want to update automatically to newer versions, saying mine "best" even i click on the line inside package.json (normally i can see a notice of a new update is available). This prob. the reason, i had the "old" system again (!), during my several tries. Sorry.

mmaietta commented 11 months ago

Ah, I understand now. Updated both electron-updater and electron-builder latest tags on npm

fjrguezg commented 10 months ago

I´ve updated to the latest versions and even updated to electron-updater@6.1.8 and I was facing the same problem. I decided to change the definition in httpExecutor.d.ts as follows:

export interface RequestHeaders extends OutgoingHttpHeaders {

the original is: export interface RequestHeaders extends OutgoingHttpHeaders {

I´ve done several tests and it works fine.