-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
element.style[key] = value throws implicit any error #11914
Comments
This behavior is correct. Specifically, interface CSSStyleDeclaration {
[index: number]: string;
} |
From W3C : https://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration
There is no string indexer on CSSStyleDeclaration. |
This is not accurate. both This is another manifestation of #7730 which is basically that: const position = "position";
div.style[position] // should behave the same way as div.style["position"] |
this should be handled correctelly when #11929 is merged in. |
closing in favor of #7730. |
My bad, TypeScript seems to handle index notation fine as long as the parameter is a string literal !
|
TypeScript Version: 2.0.3
Code
Expected behavior:
Styles are dynamically settable with dictionary access; the above snippet should set
position: absolute
ondiv
Actual behavior:
Throws
Must use format
style.setProperty(key, value);
The text was updated successfully, but these errors were encountered: