compiled icon indicating copy to clipboard operation
compiled copied to clipboard

Types on `css={…}` don't block using the top-level object from `cssMap()`

Open kylorhall-atlassian opened this issue 1 year ago • 1 comments

Describe the bug

There's no type protection when consuming cssMap incorrectly, meaning TypeScript will allow code that won't compile properly.

To Reproduce

For raw cssMap, jump into https://github.com/atlassian-labs/compiled/blob/master/packages/react/src/css-map/tests/index.test.tsx#L29 and remove .danger

-const Foo = () => <div css={styles.danger}>hello world</div>;
+const Foo = () => <div css={styles}>hello world</div>;

Same, for the strict version: https://github.com/atlassian-labs/compiled/blob/f093635244ca5accecd5093013694084408be2f7/packages/react/src/create-strict-api/tests/index.test.tsx#L162

Expected behavior

These should both have a type error.

Screenshots

No error 😞 Screenshot 2024-03-07 at 11 53 13 AM

kylorhall-atlassian avatar Mar 06 '24 22:03 kylorhall-atlassian

Thanks for raising this!

itsdouges avatar Mar 06 '24 22:03 itsdouges