Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): return type alias instead of string from css and cx #835

merged 1 commit into from Sep 12, 2021


Copy link

@Anber Anber commented Sep 12, 2021


Strictly typed css significantly simplified the creation of @linaria/eslint plugin which can check that there are no constant class names in user code.

const fooString = "foo";
const fooClass = css``;

<div className="foo" /> <!-- not ok -->
<div className={fooString} /> <!-- not ok -->
<div className={fooClass} /> <!-- ok -->
<div className={cx(condition && fooClass)} /> <!-- ok -->
<div className={cx(condition && "foo")} /> <!-- not ok -->
<div className={cx(condition && fooString)} /> <!-- not ok -->


css returns LinariaClassName instead of string.
cx returns LinariaClassName if every argument is LinariaClassName, otherwise it return string.

@Anber Anber merged commit 7eb9d94 into master Sep 12, 2021
7 checks passed
@Anber Anber deleted the strictly-typed-core branch Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant