styled-system props typing with TypeScript

I’m using styled-system and one key of the library is to use the shorthand props to allow easy and fast theming.

I’ve simplified my component but here is the interesting part:

import React from 'react'
import styled from 'styled-components'
import { color, ColorProps } from 'styled-system'

const StyledDiv = styled('div')<ColorProps>`
  ${color}
`

const Text = ({ color }: ColorProps) => {
  return <StyledDiv color={color} />
}

I have an error on the color prop which says:

Type ‘string | (string | null)[] | undefined’ is not assignable to
type ‘string | (string & (string | null)[]) | undefined’.

I think that’s because styled-system use the same naming as the native HTML attribute color and it conflicts.

How do I solve this?

219 thoughts on “styled-system props typing with TypeScript”

  1. After I initially commented I appear to have clicked the -Notify
    me when new comments are added- checkbox and from now on each time a comment is added I receive four emails with the
    same comment. There has to be an easy method you are able to remove
    me from that service? Thanks!

    Reply
  2. First of all I would like to say excellent blog!
    I had a quick question that I’d like to ask if you don’t
    mind. I was curious to find out how you center yourself and clear your head prior
    to writing. I’ve had a difficult time clearing my thoughts in getting my ideas out there.

    I truly do take pleasure in writing but it just seems like the first
    10 to 15 minutes tend to be lost simply just trying to figure out how
    to begin. Any recommendations or tips? Thank you!

    Reply
  3. Excellent items from you, man. I have bear in mind your
    stuff prior to and you are just extremely wonderful. I actually like what you
    have received right here, really like what you’re saying
    and the way in which you assert it. You make it entertaining and you continue to care
    for to keep it sensible. I cant wait to read far more from you.
    This is actually a great web site.

    Reply
  4. Hmm is anyone else encountering problems with the pictures on this
    blog loading? I’m trying to determine if its a problem on my end
    or if it’s the blog. Any suggestions would be greatly appreciated.

    Reply
  5. I’m not that much of a online reader to be honest but your
    blogs really nice, keep it up! I’ll go ahead and bookmark your
    site to come back later on. Cheers

    Reply
  6. Excellent website you have here but I was curious about if you knew
    of any message boards that cover the same topics discussed in this article?
    I’d really love to be a part of group where I can get responses from other experienced people that share the
    same interest. If you have any suggestions, please let me know.
    Bless you!

    Reply
  7. Pingback: sildenafil 50 mg
  8. Hi there fantastic website! Does running a blog similar to this take a lot of work?
    I’ve absolutely no understanding of computer programming however I
    was hoping to start my own blog in the near future. Anyway, if you have
    any recommendations or techniques for new blog owners please share.
    I understand this is off subject nevertheless I simply needed to ask.
    Thank you! cheap flights http://1704milesapart.tumblr.com/ cheap flights

    Reply
  9. Pingback: viagra
  10. Pingback: sildenafil generic
  11. Pingback: buy viagra
  12. Pingback: cost of viagra
  13. Pingback: cialis
  14. Pingback: gay dating world
  15. Pingback: cialis buy online
  16. Pingback: buy viagra online
  17. Pingback: tab cialis 20mg
  18. Pingback: viagra samples
  19. Pingback: get viagra
  20. Pingback: viagra soft sale
  21. Pingback: cialis tab 10mg
  22. There are certainly a lot of details like that to take into consideration. That is a great point to bring up. I offer the thoughts above as general inspiration but clearly there are questions like the one you bring up where the most important thing will be working in honest good faith. I don?t know if best practices have emerged around things like that, but I am sure that your job is clearly identified as a fair game. Both boys and girls feel the impact of just a moment?s pleasure, for the rest of their lives.

    Reply
  23. Pingback: tadalafil cialis
  24. Pingback: cialis dosage
  25. Pingback: brand viagra
  26. Pingback: viagra ohne rezept
  27. Pingback: herb viagra
  28. Pingback: viagra pill
  29. Pingback: viagra wirkung
  30. Pingback: what is viagra
  31. Pingback: viagra homme
  32. Pingback: viagra tablets
  33. Pingback: viagra price
  34. Pingback: sildenafil revatio
  35. Pingback: teva sildenafil
  36. Pingback: walmart viagra