Conditional array CSS prop type errors
See original GitHub issueDescribe the bug
The following code got TypeScript error. https://compiledcssinjs.com/docs/css-prop#conditional-rules
TS2322: Type 'false | { border: string; color: string; }' is not assignable to type 'string | number | void | CSSProps | AnyKeyCssProps<void>'. Type 'boolean' is not assignable to type 'string | number | void | CSSProps | AnyKeyCssProps<void>'.
Expected behavior No errors.
Screenshots

Desktop (please complete the following information):
- OS: macOS BigSir 11.1
- Browser Google Chrome
- Version 87.0.4280.141(Official Build) (x86_64)
Develop Environment
- TypeScript: 4.1.3
- @compiled/react: 0.5.2
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to validate React props using PropTypes - LogRocket Blog
Learn how to validate props with React PropTypes, React's internal mechanism for adding type checking to component props.
Read more >Typechecking With PropTypes - React
To run typechecking on the props for a component, you can assign the special propTypes property: import PropTypes from 'prop-types'; class Greeting extends ......
Read more >Allow array as sx value to have conditional 'sub-classes' #29274
sx property should accept array as value. Each element is considered as normal style object and overrides previous element's properties in case ...
Read more >How to Use PropTypes in React - freeCodeCamp
PropTypes are simply a mechanism that ensures that the passed value is of the correct datatype. This makes sure that we don't receive...
Read more >Optional chaining (?.) - JavaScript - MDN Web Docs - Mozilla
The optional chaining ( ?. ) operator accesses an object's property or calls a function. If the object accessed or function called is ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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

Update TypeScript and @compiled/react version. I’m preparing repository. Please just a moment.
@sonatard: And ternary is not supported at the moment. Its already in the pipeline.
Otherwise something like this might worked: