Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
fix(TypeScript): add CSSFunctions to CSSProperties typings (#392)
Browse files Browse the repository at this point in the history
* Add CSSFunctions to CSSProperties typings

* TypeScript tests for nested css function prop
  • Loading branch information
quicksnap authored and Kent C. Dodds committed Mar 12, 2018
1 parent 8a21d8b commit ce401a8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
14 changes: 13 additions & 1 deletion test/glamorous.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ const BuiltinStyledWithFragment: JSX.Element = (
const cssProps = {
":active": {
color: "purple"
}
},
};

const BuiltinStyledWithCSSPseudoProps = (
Expand All @@ -626,3 +626,15 @@ const BuiltinStyledWithCSSPseudoProps = (
<glamorous.A css={cssProps} />
</div>
);

const nestedCssProps = [
{ color: 'red', },
() => ({ fontSize: 123 }),
() => () => () => [{ border: '1px solid black'}],
];

const NestedStyleFunctions = (
<div>
<glamorous.Div css={nestedCssProps} />
</div>
)
10 changes: 9 additions & 1 deletion typings/css-properties.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,14 @@ export interface CSSProperties
CSSPropertiesPseudo,
CSSPropertiesLossy {}

export type CSSPropertiesRecursive = CSSProperties | CSSPropertiesArray
export type CSSPropertiesRecursive =
| CSSProperties
| CSSPropertiesArray
| CSSFunction

// TODO: This could be made generic. Issue PR if you're so inclined!
export interface CSSFunction {
(props: {}): CSSPropertiesRecursive
}

export interface CSSPropertiesArray extends Array<CSSPropertiesRecursive> {}

0 comments on commit ce401a8

Please sign in to comment.