Guest User

Untitled

a guest
Jul 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import * as CSS from 'csstype'
  2.  
  3. type SingleOrArray<Properties, T extends keyof Properties> = {
  4. [P in T]: Properties[P] | Array<Properties[P]>
  5. }
  6.  
  7. type CSSPropertiesLoosePseudo = { [K in CSS.Pseudos]?: CSSPropertiesLoose }
  8. type CSSPropertiesPseudo = { [K in CSS.Pseudos]?: CSSProperties }
  9.  
  10. type CSSPropertiesComplete = SingleOrArray<CSS.Properties, keyof CSS.Properties>
  11.  
  12. interface CSSPropertiesLossy {
  13. [propertyName: string]:
  14. | string
  15. | number
  16. | CSSPropertiesComplete
  17. | undefined
  18. | Array<CSSPropertiesComplete[keyof CSSPropertiesComplete]>
  19. | CSSPropertiesLossy
  20. }
  21.  
  22. interface CSSPropertiesLoose
  23. extends CSSPropertiesComplete,
  24. CSSPropertiesLoosePseudo,
  25. CSSPropertiesLossy {}
  26.  
  27. interface CSSProperties extends CSSPropertiesComplete, CSSPropertiesPseudo {}
  28.  
  29. type CSSFunction = (props: {}) => Style
  30.  
  31. type Style =
  32. | CSSPropertiesComplete & CSSPropertiesPseudo
  33. | CSSFunction
  34. | StyleArray
  35.  
  36. interface StyleArray extends Array<Style | undefined> {}
  37.  
  38. type StyleLoose = CSSPropertiesLoose | CSSFunction | StyleLooseArray | boolean
  39.  
  40. interface StyleLooseArray extends Array<StyleLoose | undefined> {}
Add Comment
Please, Sign In to add comment