Skip to content

fix(lib): allow CSSStyleValue in Keyframe index signature#63436

Closed
creazyfrog wants to merge 2 commits intomicrosoft:mainfrom
creazyfrog:fix/keyframe-css-typed-om
Closed

fix(lib): allow CSSStyleValue in Keyframe index signature#63436
creazyfrog wants to merge 2 commits intomicrosoft:mainfrom
creazyfrog:fix/keyframe-css-typed-om

Conversation

@creazyfrog
Copy link
Copy Markdown

Summary

Fixes #63325

The Web Animations API is compatible with the CSS Typed Object Model — properties like transform can accept CSSTransformValue objects (CSSRotate, CSSTranslate, etc.) at runtime in modern browsers. However, the Keyframe index signature only allowed string | number | null | undefined, causing a type error on valid code:

element.animate([
    { transform: 'rotate(0deg)' },
    { transform: new CSSRotate(45, 0, 0, CSSNumericValue.parse('90deg')) } // ❌ TS error before fix
], { duration: 500 })

Fix

Add CSSStyleValue — the common base class for all CSS Typed OM types — to the index signature:

 interface Keyframe {
     composite?: CompositeOperationOrAuto;
     easing?: string;
     offset?: number | null;
-    [property: string]: string | number | null | undefined;
+    [property: string]: string | number | null | undefined | CSSStyleValue;
 }

Using the base class rather than enumerating individual subclasses (CSSTransformValue, CSSNumericValue, CSSKeywordValue, …) keeps the change minimal and future-proof — any CSS Typed OM subclass is automatically covered.

Spec reference

The Web Animations spec and MDN element.animate() confirm that CSS Typed OM values are valid for keyframe properties in supporting browsers.

The Simplified Chinese translation of error TS2561 had the subject and
object swapped: it read "type '{1}' does not exist in '{0}'" instead of
"'{0}' does not exist in type '{1}'", inverting the logical relationship
and misleading Chinese-speaking developers.

Three corrections applied:
- Restructure "但"{0}"中不存在类型"{1}"" → "但"{0}"在类型"{1}"中不存在"
  (property does not exist in type, not type does not exist in property)
- Remove redundant 的: "已知的属性" → "已知属性"
- Improve closing phrase: "是否要写入 {2}?" → "您是否想写"{2}"?"
  (add quotes around the suggestion, use natural phrasing)

Fixes microsoft#63274

Signed-off-by: creazyfrog <rohitcse.gec@gmail.com>
The Web Animations API is compatible with the CSS Typed Object Model:
properties like `transform` accept CSSTransformValue objects (CSSRotate,
CSSTranslate, etc.) at runtime in modern browsers, but the Keyframe
index signature only permitted `string | number | null | undefined`.

Adding CSSStyleValue — the common base class for all CSS Typed OM
types — covers CSSTransformValue, CSSNumericValue, CSSKeywordValue,
CSSUnitValue, and any future subclasses without needing to enumerate
each one individually.

Before:
  [property: string]: string | number | null | undefined;

After:
  [property: string]: string | number | null | undefined | CSSStyleValue;

Fixes microsoft#63325

Signed-off-by: creazyfrog <rohitcse.gec@gmail.com>
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Apr 26, 2026
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Apr 26, 2026
@typescript-bot
Copy link
Copy Markdown
Collaborator

It looks like you've sent a pull request to update some generated declaration files related to the DOM. These files aren't meant to be edited by hand, as they are synchronized with files in the TypeScript-DOM-lib-generator repository. You can read more here. For house-keeping purposes, this pull request will be closed.

@github-project-automation github-project-automation Bot moved this from Not started to Done in PR Backlog Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

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