Skip to content

fix: add CSSStyleValue to Keyframe index signatures#2466

Open
Ankitajainkuniya wants to merge 1 commit intomicrosoft:mainfrom
Ankitajainkuniya:fix/keyframe-css-typed-om
Open

fix: add CSSStyleValue to Keyframe index signatures#2466
Ankitajainkuniya wants to merge 1 commit intomicrosoft:mainfrom
Ankitajainkuniya:fix/keyframe-css-typed-om

Conversation

@Ankitajainkuniya
Copy link
Copy Markdown

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
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

Thanks for the PR!

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

@Ankitajainkuniya
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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

2 participants