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

Unable to specify options with html2canvas in TypeScript after recent release #1854

Closed
rathodsanjay opened this issue May 29, 2019 · 4 comments · Fixed by #1861
Closed

Unable to specify options with html2canvas in TypeScript after recent release #1854

rathodsanjay opened this issue May 29, 2019 · 4 comments · Fixed by #1861

Comments

@rathodsanjay
Copy link

rathodsanjay commented May 29, 2019

I am using html2canvas in an Angular application based on TypeScript. I am unable to specify options with html2canvas since recent release. It expects some id property in the options provided.

Following is my code:

var options = { logging: false };
html2canvas(element, options);

Error:
Property 'id' is missing in type '{ logging: false }' but required in type 'CloneOptions'

Specifications:

  • html2canvas version tested with: v1.0.0-rc.2
  • Browser & version: Google Chrome v70.0.3538.77
  • Operating system: Windows 10
@rathodsanjay rathodsanjay changed the title Unable to specify options with html2canvas after recent release Unable to specify options with html2canvas in TypeScript after recent release May 29, 2019
@hakimio
Copy link

hakimio commented May 29, 2019

As a workaround you can cast to any:

await html2canvas(htmlEl, <any>{
    windowWidth: htmlEl.clientWidth,
    windowHeight: htmlEl.clientHeight,
    scale: 2,
    logging: false
});

@rathodsanjay
Copy link
Author

@hakimio thanks, but for time being, I just downgraded the version in my package.json to use rc.1 and the builds are passing!

@val1984
Copy link
Contributor

val1984 commented May 29, 2019

My workaround for the time being is to cast the options as Options:

const opts: Partial<Options> = {
  logging: false,
};
html2canvas(body, opts as Options);

@ovidioreyna
Copy link

Can confirm that Angular 7 build is failing with 1.0.0-rc.2. Just resolved this issue for our team. 1.0.0-rc.1 worked for us, but we're playing it safe and went back to our initial version of 1.0.0-alpha.12.

Error we received seems to have to do with options.

Error produced:

Argument of type '{ windowWidth: number; }' is not assignable to parameter of type 'Options'.
  Property 'id' is missing in type '{ windowWidth: number; }' but required in type 'CloneOptions'.

Code for html2canvas is as follows:

html2canvas(data, {windowWidth: 1500}).then()

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

Successfully merging a pull request may close this issue.

4 participants