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

electron.d.ts error using TS2.6.0-rc in strict mode #79

Closed
xaviergonz opened this issue Oct 21, 2017 · 7 comments
Closed

electron.d.ts error using TS2.6.0-rc in strict mode #79

xaviergonz opened this issue Oct 21, 2017 · 7 comments

Comments

@xaviergonz
Copy link

node_modules/electron/electron.d.ts(5390,13): error TS2430: Interface 'WebviewTag' incorrectly extends interface 'HTMLElement'.
  Types of property 'addEventListener' are incompatible.
      Type '{ (event: "load-commit", listener: (event: LoadCommitEvent) => void, useCapture?: boolean | undef...' is not assignable to type '{ <K extends "error" | "waiting" | "progress" | "ended" | "change" | "input" | "select" | "abort"...'.
        Types of parameters 'listener' and 'listener' are incompatible.
          Type 'EventListenerOrEventListenerObject' is not assignable to type '(event: LoadCommitEvent) => void'.
            Type 'EventListenerObject' is not assignable to type '(event: LoadCommitEvent) => void'.
              Type 'EventListenerObject' provides no match for the signature '(event: LoadCommitEvent): void'.

I think it is due to this new strict change:
https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#strict-function-types

@sandersn
Copy link
Contributor

This happens because the addEventListener/removeEventListener overloads in WebviewTag are incorrect. When you override a method in Typescript, the overloads of the base's method are not copied to the overriding method in the derived class. They're just checked for compatibility. You have to copy them yourself if you want them.

Typescript 2.6 catches this because of strict function types, although it missed it before. The fix is to copy the add/RemoveEventListener overloads from HTMLElement to the very bottom of the list of overloads in WebviewTag.

I'll do it this afternoon if I can figure out how to build electron.d.ts.

@styfle
Copy link

styfle commented Nov 13, 2017

Thanks for fixing!

I am still getting the same error.

Was this changed released yet, and if so which version?

@MarshallOfSound
Copy link
Member

@styfle This change will only take affect in Electron versions released after #81 was merged

@craxal
Copy link

craxal commented Nov 28, 2017

I'm still encountering this issue.

  • types/node: 7.0.48
  • electron: 1.7.9
  • typescript: 2.6.2

@ccorcos
Copy link

ccorcos commented Nov 29, 2017

Me too!

@vladimiry
Copy link

vladimiry commented Dec 6, 2017

There is no such issue with the latest electron@1.8.2-beta.3 version, previous electron@1.8.2-beta.2 was affected.

@KeitaIkeda
Copy link

Hi guys
I'm using Electron: 1.8.2, but still encountering this issue.

How to fix it?

let webview: WebviewTag = document.getElementById('mainWebview')!;

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

No branches or pull requests

8 participants