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

Type definition for HTMLElement does not include animate() function (lib.es6.t.ds) #21492

Closed
fr0 opened this issue Jan 30, 2018 · 4 comments
Closed
Assignees
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@fr0
Copy link

fr0 commented Jan 30, 2018

Search Terms:
HTMLElement animate lib.es6.t.ds

Code

let e: HTMLElement;
// ... assign e here ...
e.animate([
    {transform: 'translateX(0px)' }, {transform: 'translateX(100px)' }
  ], {
    duration: 200,
    easing: 'ease-in-out'
  });

Expected behavior:

There should not be a compiler error with the above code.

Actual behavior:

There is a compiler error: Property 'animate' does not exist on type 'HTMLElement'.

Playground Link:

https://www.typescriptlang.org/play/#src=let%20e%3A%20HTMLElement%3B%0D%0A%2F%2F%20...%20assign%20e%20here%20...%0D%0Ae.animate(%5B%0D%0A%20%20%20%20%7Btransform%3A%20'translateX(0px)'%20%7D%2C%20%7Btransform%3A%20'translateX(100px)'%20%7D%0D%0A%20%20%5D%2C%20%7B%0D%0A%20%20%20%20duration%3A%20200%2C%0D%0A%20%20%20%20easing%3A%20'ease-in-out'%0D%0A%20%20%7D)%3B%0D%0A

Related Issues:

None

Other information:

web-animations spec: https://www.w3.org/TR/web-animations-1/
MDN link: https://developer.mozilla.org/en-US/docs/Web/API/Element/animate

@mhegazy mhegazy added Bug A bug in TypeScript Help Wanted You can do this Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Jan 30, 2018
@mhegazy mhegazy added this to the Community milestone Jan 30, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Jan 30, 2018

PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.

benbraou added a commit to benbraou/TSJS-lib-generator that referenced this issue Jan 31, 2018
benbraou added a commit to benbraou/TSJS-lib-generator that referenced this issue Jan 31, 2018
benbraou added a commit to benbraou/TSJS-lib-generator that referenced this issue Feb 4, 2018
@mhegazy mhegazy modified the milestones: Community, TypeScript 2.8 Feb 5, 2018
@mhegazy mhegazy self-assigned this Feb 5, 2018
@mhegazy mhegazy added the Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet label Feb 5, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Feb 5, 2018

thanks @benbraou!

@mhegazy mhegazy reopened this Feb 8, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Feb 12, 2018
@mhegazy mhegazy removed the Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet label Feb 12, 2018
@brasilino
Copy link

I'm having this same error. To correct it should I upgrade the version of typescript to 2.8?

I'am using:

"ionic-angular": "3.9.2",
"typescript": "2.4.2"

@mhegazy
Copy link
Contributor

mhegazy commented May 16, 2018

you can either upgrade to 2.8 or later, or in a .d.ts file in your project add:

interface HTMLElement { 
    animate(keyframes: AnimationKeyFrame | AnimationKeyFrame[], options: number | AnimationOptions): Animation;
}

interface AnimationKeyFrame {
    easing?: string | string[];
    offset?: number | null | (number | null)[];
    [index: string]: string | number | number[] | string[] | null | (number | null)[] | undefined;
}

interface AnimationOptions {
    delay?: number;
    direction?: "normal" | "reverse" | "alternate" | "alternate-reverse";
    duration?: number;
    easing?: string;
    endDelay?: number;
    fill?: "none" | "forwards" | "backwards" | "both" | "auto";
    id?: string;
    iterationStart?: number;
    iterations?: number;
}

@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants