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

Investigate whether EventTarget should be constructable #23

Closed
DanielRosenwasser opened this issue Nov 11, 2015 · 8 comments
Closed

Investigate whether EventTarget should be constructable #23

DanielRosenwasser opened this issue Nov 11, 2015 · 8 comments

Comments

@DanielRosenwasser
Copy link
Member

It seems like it will always throw an error, so perhaps we shouldn't mark it as constructable.

@rielz
Copy link

rielz commented Dec 31, 2015

Indeed. The DOM spec does not say it has a constructor:
[WHATWG] [W3C]

@zhengbli
Copy link
Contributor

zhengbli commented Jan 6, 2016

@mhegazy would removing the constructor affect the typeof operator on this type?

@DanielRosenwasser
Copy link
Member Author

As a type query, or a typeof expression?

As a type query on something of type EventTarget, you should see no difference.

If using a typeof expression, you'll get "object" back at runtime anyway.

So either way, there should be no difference.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 6, 2016

i believe @zhengbli meant instanceof checks. an yes ti will be an error to call x instanceof EventTarget

@zhengbli
Copy link
Contributor

zhengbli commented Jan 6, 2016

@DanielRosenwasser @mhegazy sorry I meant instanceof check.

@rielz
Copy link

rielz commented Jan 6, 2016

It would be sufficient to only remove the constructor (not the whole declared var).
EventTarget and its prototype property do exist in the global namespace.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 6, 2016

the constructor does exist at runtime too, it is just illigal to call. This is the same for almost all DOM classes. i think the right fix here is to switch all DOM declarations to classes, and make thier constructors private. this requires microsoft/TypeScript#2341

@zhengbli
Copy link
Contributor

zhengbli commented Jan 8, 2016

As this issue belongs to a larger parent issue, I'm closing this one.

@zhengbli zhengbli closed this as completed Jan 8, 2016
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

4 participants