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
merged 1 commit into from Sep 12, 2021

Conversation

Anber
Copy link
Collaborator

@Anber Anber commented Sep 12, 2021

Motivation

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 -->

Summary

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
@Anber Anber deleted the strictly-typed-core branch September 12, 2021 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant