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

Image constructor / inheritance not consistent #172

Open
lgrignon opened this issue Oct 14, 2016 · 1 comment
Open

Image constructor / inheritance not consistent #172

lgrignon opened this issue Oct 14, 2016 · 1 comment
Labels

Comments

@lgrignon
Copy link
Collaborator

@lgrignon lgrignon commented Oct 14, 2016

in Javascript, you can do

var img = new Image(200, 200);

and in TypeScript

var img: HTMLImageElement = new Image(200, 200);

due to the declaration in lib.d.ts :

declare var Image: {new(width?: number, height?: number): HTMLImageElement; };

In JSweet, this is impossible, jsweet.dom.Image does not extend HTMLImageElement and jsweet.dom.Globals.Image is an instance of jsweet.dom.Image which is no use for this case.

Even worse:

HTMLImageElement img = any(new Image(200, 200));

produces:

var img = {};
@lgrignon
Copy link
Collaborator Author

@lgrignon lgrignon commented Oct 14, 2016

NB: there is an obvious workaround with

HTMLImageElement img = document.createElement("img");
img.width = 200;
img.height = 200;
@renaudpawlak renaudpawlak added this to the 2.1.0 milestone Jul 24, 2017
@lgrignon lgrignon removed this from the 2.1.0 milestone May 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.