fix: add CSSStyleValue to Keyframe index signatures - #2466
Conversation
… 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
|
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. |
|
@microsoft-github-policy-service agree |
Adam Naji (Bashamega)
left a comment
There was a problem hiding this comment.
This seems correct Kagami Sascha Rosylight (@saschanaz)
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 |
|
There was an issue merging, maybe try again saschanaz. Details |
|
LGTM |
|
There was an issue merging, maybe try again saschanaz. Details |
|
Jake Bailey (@jakebailey) has something happened on the token again? |
|
I don't think so? You were able to merge just a bit ago, I suspect a badly timed outage. Maybe try again quick |
|
LGTM |
|
There was an issue merging, maybe try again saschanaz. Details |
|
🤔 |
|
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 https://github.com/orgs/community/discussions/194847#discussioncomment-16817164 I can fix this but for now I'll just hit merge 😄 |
|
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.... |
Summary
CSSStyleValueto theKeyframeandPropertyIndexedKeyframesindex signatureselement.animate(),KeyframeEffect(), andsetKeyframes()Problem
The Web Animations API supports passing CSS Typed OM values (e.g.,
CSSUnitValue,CSSKeywordValue,CSSTransformValue) to animation keyframes. This is valid at runtime:However, the current
Keyframeinterface only acceptsstring | number | null | undefinedin its index signature, causing a TypeScript error for this valid usage.Changes
inputfiles/overridingTypes.jsonc:Keyframe:[property: string]: string | number | CSSStyleValue | null | undefinedPropertyIndexedKeyframes:[property: string]: string | string[] | number | CSSStyleValue | CSSStyleValue[] | null | (number | null)[] | undefinedComputedKeyframeis intentionally left unchanged —getKeyframes()returns computed string values, notCSSStyleValueobjects.Motivation
KeyframeAnimationOptionsinterface already usesCSSNumericValue | CSSKeywordValueforrangeStart/rangeEnd, showing these types are recognized for animationsFixes microsoft/TypeScript#63325