Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.0.5 fails to compile #110

Closed
k8stone opened this issue Feb 21, 2022 · 6 comments · Fixed by #111
Closed

Release 2.0.5 fails to compile #110

k8stone opened this issue Feb 21, 2022 · 6 comments · Fixed by #111
Labels

Comments

@k8stone
Copy link

k8stone commented Feb 21, 2022

Issue discover using a project that depends on an up-to-date Electron, currently 17.0.1. Three new lines in index.d.ts are the source of the problem:

line 42:
export var nativeImage: typeof Electron.NativeImage;

line 57:
export var webContents: typeof Electron.WebContents;

line 58:
export var webFrameMain: typeof Electron.WebFrameMain;

All three can be fixed by using the type of the exported instances rather than relying on types that aren't directly available outside the Electron package:

export var nativeImage: typeof Electron.nativeImage;
export var webContents: typeof Electron.webContents;
export var webFrameMain: typeof Electron.webFrameMain;

@oleg-tsybulsky
Copy link

Same error, Electron 17.0.1

@nibbles83
Copy link

Same error Electron 17.0.1 @electron/remote 2.0.4 builds fine, 2.0.5 does not.

Error: Error: node_modules/@electron/remote/index.d.ts:42:41 - error TS2551: Property 'NativeImage' does not exist on type 'typeof CrossProcessExports'.
42 export var nativeImage: typeof Electron.NativeImage;

Error: Error: node_modules/@electron/remote/index.d.ts:57:41 - error TS2551: Property 'WebContents' does not exist on type 'typeof CrossProcessExports'.
57 export var webContents: typeof Electron.WebContents;

Error: Error: node_modules/@electron/remote/index.d.ts:58:42 - error TS2551: Property 'WebFrameMain' does not exist on type 'typeof CrossProcessExports'.
58 export var webFrameMain: typeof Electron.WebFrameMain;

@k8stone
Copy link
Author

k8stone commented Feb 23, 2022

FYI - It looks like these types are exported in Electron 17.1.0. It would still be nice to have a more flexible solution, but that's at least workable presuming 17.1.0 doesn't break anything significant.

@nornagon
Copy link
Member

cc @andersk looks like something went wrong with #108 and/or #109

andersk added a commit to andersk/electron-remote that referenced this issue Feb 24, 2022
@andersk
Copy link
Contributor

andersk commented Feb 24, 2022

Thanks for the ping. This seems to be a change between Electron 14 and 15. Electron 14 declares

declare namespace Electron {
  class NativeImage {  }
  class WebContents extends NodeEventEmitter {  }
  class WebFrameMain extends NodeEventEmitter {  }
  const nativeImage: typeof NativeImage;
  const webContents: typeof WebContents;
  const webFrameMain: typeof WebFrameMain;
}

declare module 'electron' {
  export = Electron;
}

where the difference between nativeImage: typeof NativeImage and native: NativeImage is that the former (correctly) prohibits access to non-static members.

But Electron 15 declares

declare namespace Electron {
  class NativeImage {  }
  class WebContents extends NodeEventEmitter {  }
  class WebFrameMain extends NodeEventEmitter {  }
  namespace CrossProcessExports {
    const nativeImage: typeof NativeImage;
    type NativeImage = Electron.NativeImage;
    const webContents: typeof WebContents;
    type WebContents = Electron.WebContents;
    const webFrameMain: typeof WebFrameMain;
    type WebFrameMain = Electron.WebFrameMain;
  }
}

declare module 'electron' {
  export = Electron.CrossProcessExports;
}

where NativeImage is only exported as a type alias, not a class, so typeof NativeImage can no longer be used from outside.

I think typeof Electron.nativeImage will do the right thing in both versions, so I opened #111 to switch to that.

nornagon pushed a commit that referenced this issue Mar 15, 2022
* fix: types for nativeImage, webContents, webFrameMain again

Fixes #110.

Signed-off-by: Anders Kaseorg <[email protected]>

* ci: Remove Electron 11

ShareMenu and webFrameMain are new in Electron 12.

Signed-off-by: Anders Kaseorg <[email protected]>

* fix: Remove exclusion of index.d.ts from tsconfig

This was previously excluded (#48) because of CI failures due to
index.d.ts referencing files in dist.  Those references were later
removed (#58), so we can include it again to have CI verify that
index.d.ts type checks.

Signed-off-by: Anders Kaseorg <[email protected]>
@electron-bot
Copy link

🎉 This issue has been resolved in version 2.0.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants