Skip to content

TypeScript type error when following docs to config global dialog animation #2296

@ivanbacher

Description

@ivanbacher

Following the docs to config global animations for all dialogs and I get a typescript type error

settings.options.show = (dom) => dom.root.animate(
      [{ transform: 'scale(0)' }, { transform: 'scale(1)' }], 
      { duration: 150 }
    )
Type 'Animation' is not assignable to type 'void | Promise<void>'.ts(2322)
dialog-impl-standard.d.ts(22, 12): The expected type comes from the return type of this signature.
(method) Animatable.animate(keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: number | KeyframeAnimationOptions): Animation

This:

settings.options.show = dom => {
      dom.root.animate(
        [{ transform: 'scale(0)' }, { transform: 'scale(1)' }], 
        { duration: 150 }
      )
    }

or this:

settings.options.show = dom => {
      return new Promise(resolve => {
        const animation = dom.root.animate(
          [{ transform: 'scale(0)' }, { transform: 'scale(1)' }], 
          { duration: 150 }
        )

        animation.onfinish = () => resolve(null)
      })
    }

Seem to get rid of the type error.

Should the documentation be updated to reflect this?

Metadata

Metadata

Assignees

Labels

DocsDocumentation needs to be added/improved/corrected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions