Add support for CSS objects to the styled-components CSS prop (#35774)

* Add support for CSS objects to the styled-components CSS prop

This is valid styled-components code, but TypeScript throws an error:

```JS
<div css={{ color: 'blue' }} />
```

* Uncomment test for objects in css prop
This commit is contained in:
Max Stoiber 2019-06-04 20:30:41 +02:00 committed by Andrew Casey
parent 4412049ea6
commit 6d20eb981d
2 changed files with 2 additions and 5 deletions

View File

@ -510,6 +510,7 @@ export class StyleSheetManager extends React.Component<
// ONLY string literals and inline invocations of css`` are supported, anything else crashes the plugin
export type CSSProp<T = AnyIfEmpty<DefaultTheme>> =
| string
| CSSObject
| FlattenInterpolation<ThemeProps<T>>;
export default styled;

View File

@ -809,11 +809,7 @@ function cssProp() {
return (
<>
<div css="background: blue;" />
{/*
For some reason $ExpectError doesn't work on this expression.
Only strings work, objects crash the plugin.
<div css={{ background: "blue" }} />
*/}
<div css={{ background: "blue" }} />
<div
// would be nice to be able to turn this into an error as it also crashes the plugin,
// but this is how optional properties work in TypeScript...