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

Issue with TypeScript type definitions #1855

Closed
hakimio opened this issue May 29, 2019 · 2 comments · Fixed by #1861
Closed

Issue with TypeScript type definitions #1855

hakimio opened this issue May 29, 2019 · 2 comments · Fixed by #1861

Comments

@hakimio
Copy link

hakimio commented May 29, 2019

Pretty much all CloneOptions, RenderOptions and Options interface properties should be optional or at least when declaring Options type you should use "|" instead of "&"

export declare type Options = CloneOptions | RenderOptions | {
    allowTaint: boolean;
    backgroundColor: string;
    foreignObjectRendering: boolean;
    imageTimeout: number;
    logging: boolean;
    proxy?: string;
    removeContainer?: boolean;
    useCORS: boolean;
};
@val1984
Copy link
Contributor

val1984 commented May 29, 2019

html2canvas should definitely accept Partial<Options> as its second argument.
But Options type definition seems fine to me otherwise, no need to make it a union type.

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

const opts: Partial<Options> = {
  // my options, nicely typechecked
};
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.

3 participants