Skip to content

fix: add CSSStyleValue to Keyframe index signatures - #2466

Merged
Jake Bailey (jakebailey) merged 1 commit into
microsoft:mainfrom
Ankitajainkuniya:fix/keyframe-css-typed-om
Sep 4, 2026
Merged

fix: add CSSStyleValue to Keyframe index signatures#2466
Jake Bailey (jakebailey) merged 1 commit into
microsoft:mainfrom
Ankitajainkuniya:fix/keyframe-css-typed-om

Conversation

@Ankitajainkuniya

Copy link
Copy Markdown
Contributor

Summary

  • Adds CSSStyleValue to the Keyframe and PropertyIndexedKeyframes index signatures
  • Enables passing CSS Typed Object Model values directly to element.animate(), KeyframeEffect(), and setKeyframes()

Problem

The Web Animations API supports passing CSS Typed OM values (e.g., CSSUnitValue, CSSKeywordValue, CSSTransformValue) to animation keyframes. This is valid at runtime:

element.animate([
  { transform: new CSSTranslate(CSS.px(0), CSS.px(0)) },
  { transform: new CSSTranslate(CSS.px(100), CSS.px(100)) }
], { duration: 500 });

However, the current Keyframe interface only accepts string | number | null | undefined in its index signature, causing a TypeScript error for this valid usage.

Changes

inputfiles/overridingTypes.jsonc:

  • Keyframe: [property: string]: string | number | CSSStyleValue | null | undefined
  • PropertyIndexedKeyframes: [property: string]: string | string[] | number | CSSStyleValue | CSSStyleValue[] | null | (number | null)[] | undefined

ComputedKeyframe is intentionally left unchanged — getKeyframes() returns computed string values, not CSSStyleValue objects.

Motivation

Fixes microsoft/TypeScript#63325

… signatures

The Web Animations API allows passing CSS Typed Object Model values
(CSSStyleValue and its subtypes like CSSUnitValue, CSSKeywordValue,
CSSTransformValue, etc.) directly to animation keyframes via
element.animate() and KeyframeEffect. However, the current Keyframe
and PropertyIndexedKeyframes interfaces only accept string | number,
causing type errors for valid CSS Typed OM usage.

This adds CSSStyleValue to the index signatures of:
- Keyframe: accepts CSSStyleValue for individual keyframe properties
- PropertyIndexedKeyframes: accepts CSSStyleValue and CSSStyleValue[]

ComputedKeyframe is intentionally left unchanged since getKeyframes()
returns computed string values, not CSSStyleValue objects.

Fixes microsoft/TypeScript#63325
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR!

This section of the codebase is owned by Kagami Sascha Rosylight (@saschanaz) - if they write a comment saying "LGTM" then it will be merged.

@Ankitajainkuniya

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@Bashamega Adam Naji (Bashamega) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saschanaz

Kagami Sascha Rosylight (saschanaz) commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
const element = document.createElement('div')

element.animate([
    { transform: 'rotate(0deg)'},
    { transform: new CSSRotate(45, 0, 0, CSSNumericValue.parse('90deg'))}
], {
    duration: 500
}).effect.getKeyframes()[1]

Agreed, and this works on Safari/Chrome.

LGTM

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

There was an issue merging, maybe try again saschanaz. Details

@saschanaz

Copy link
Copy Markdown
Contributor

LGTM

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

There was an issue merging, maybe try again saschanaz. Details

@saschanaz

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) has something happened on the token again?

@jakebailey

Copy link
Copy Markdown
Member

I don't think so? You were able to merge just a bit ago, I suspect a badly timed outage. Maybe try again quick

@saschanaz

Copy link
Copy Markdown
Contributor

LGTM

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

There was an issue merging, maybe try again saschanaz. Details

@saschanaz

Copy link
Copy Markdown
Contributor

🤔

@jakebailey

Copy link
Copy Markdown
Member

Figured it out; it's because the PR base is before we edited workflow files, and so GitHub refuses to allow the GHA token to merge unless workflows: write is given.

https://github.com/orgs/community/discussions/194847#discussioncomment-16817164

I can fix this but for now I'll just hit merge 😄

@jakebailey
Jake Bailey (jakebailey) merged commit 195bfaf into microsoft:main Sep 4, 2026
8 checks passed
@jakebailey

Copy link
Copy Markdown
Member

Agh, GHA can't grant that, only app tokens. Hm. I'll figure something out when I can, but I'm of course watching the repo.

That or, it's because the author has "first time contributor", but....

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 this pull request may close these issues.

lib.dom.d.ts: Keyframe interface should allow CSS Typed Object Model objects like CSSTransformValue, etc

5 participants