Improve CSSStyleDeclaration typings
See original GitHub issueNot every string should be allowed in properties of the CSSStyleDeclaration
interface, such as display
, overflow
, etc. The TypeStyle project seems to have put quite some effort into this already, from which inspiration could be taken.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:15
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Improve CSSStyleDeclaration typings · Issue #17827 - GitHub
Just a question: Why is the index type of CSSStyleDeclaration 's index signature number and not string ? In case you want to...
Read more >CSSStyleDeclaration - Web APIs | MDN
Chrome Edge
CSSStyleDeclaration Full support. Chrome1. Toggle history Full support. Edge12. Toggle...
@@iterator Full support. Chrome51. Toggle history Full support. Edge18. Toggle...
cssFloat Full support. Chrome1....
Read more >Union type of Partial<CssStyleDeclaration> and dictionary ...
First off, the current behavior of your code is because the way discriminated union type works. CSSStyleDeclaration doesn't have a index ...
Read more >CSSStyleDeclaration Object - W3Schools
The CSSStyleDeclaration object represents a collection of CSS property-value pairs. CSSStyleDeclaration Object Properties. Property, Description. cssText, Sets ...
Read more >TypeScript and React: Styles and CSS - fettblog.eu
They have roughly the same properties as the CSSStyleDeclaration interface. When using React typings, these properties are already typed through csstype.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just a question: Why is the index type of
CSSStyleDeclaration
’s index signaturenumber
and notstring
?In case you want to apply a list of styles to
HTMLElement.style
one (like me) could try:My current workaround is a cast to
any
:which is really ugly.
@GlenPerkins Just use:
mydiv.style.setProperty('font-size', '24px')
andmydiv.style.getPropertyValue('font-size')