Microsoft/TypeScript
GitHub ã§èŠãError when accessing CSS property value using kebab case in `CSSStyleDeclaration` object
Open
#59,968 opened on 2024幎9æ14æ¥
BugDomain: lib.d.tsHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
"CSS property value kebab case dash", "CSSStyleDeclaration", "getComputedStyle", "getPropertyValue"
ð Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about "CSSStyleDeclaration", "getComputedStyle"
⯠Playground Link
ð» Code
getComputedStyle(document.body)['background-color']
ð Actual behavior
TypeScript reports following error:
Element implicitly has an 'any' type because index expression is not of type 'number'.
ð Expected behavior
TypeScript should not report any error.
Additional information about the issue
If I update the file node_modules/typescript/lib/lib.dom.d.ts to include background-color as follows:
interface CSSStyleDeclaration {
// ...
'background-color': string;
// ...
}
the error does not occur for background-color property.