-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Reorganize @emotion/utils
types
#3076
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 67518ed The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 67518ed:
|
I realized that in |
0b9529c
to
bf56fb8
Compare
[key: string]: string | true | ||
} | ||
registered: RegisteredCache | ||
sheet: EmotionStyleSheet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only thing I can think of that would solve the constructor
issue, let me know if you don't want it or if you have any thoughts
I downloaded the build via |
bf56fb8
to
1776c40
Compare
':hover': css` | ||
color: hotpink; | ||
` | ||
}) | ||
|
||
// $ExpectError | ||
css(() => 'height: 300px;') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Andarist Are there reasons why this and below it are not allowed even though they worked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this css
call doesn't run in any kind of "context", we don't have any arguments to give to this function so we don't allow functions to be passed here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'm guessing, even though it works in nature, there's no point in doing this as it doesn't run in any context?
I'm looking for reasons why we do not allow these things in TS due to type complaining, but it's working just fine.
1776c40
to
361296c
Compare
| CSSProperties[K] | ||
| Array<Extract<CSSProperties[K], string>> | ||
} | ||
|
||
export type CSSPseudos = { [K in CSS.Pseudos]?: CSSObject } | ||
export type CSSPseudos = { [K in CSS.Pseudos]?: CSSInterpolation } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks legit but I will have to reexamine this more closely later.
| null | ||
| undefined | ||
| false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I guess those were added to account for "a test that allows false value but not in TS"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but a weird thing happened, I managed to build my own serializer based on the implementation but using js-beautify
like beautify.css()
instead of using @emotion/css-prettifier
.
When I used it and passed null
like css({ textAlign: null })
, it created a weird selector like .emotion-0 textAlign {}
but when I switched to @emotion/css-prettifier
, it removed it.
The @emotion/css-prettifier
also removes the empty selector like .emotion-0 {}
which I guess does the same thing hence why in the test we're not seeing these weird things.
It's not an issue as I can just use that lib you guys already have but just a weird thing that it only happens when it's null
packages/utils/types/index.d.ts
Outdated
import type { SerializedStyles } from '@emotion/serialize' | ||
import type { RegisteredCache, EmotionCache } from '@emotion/cache' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't import from other packages here because we don't depend on them. This is also true at type level - even if we still don't import anything at runtime.
I'd keep the existing types here (to avoid breaking changes) but I'd deprecate them in favor of the proper ones exported by specific packages). In the future, we should just remove export
from those local types here. This way we'll be able to depend on TS structural type system without introducing any dependencies to this package.
361296c
to
67518ed
Compare
cache: EmotionCache, | ||
serialized: SerializedStyles, | ||
cache: EmotionStyleCache, | ||
serialized: EmotionSerializedStyles, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Andarist This is what I ended up doing otherwise, they would be incompatible to each other.
@@ -2,6 +2,7 @@ | |||
"extends": "@definitelytyped/dtslint/dtslint.json", | |||
"rules": { | |||
"array-type": [true, "generic"], | |||
"semicolon": false | |||
"semicolon": false, | |||
"no-redundant-jsdoc": false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Andarist I tried all of these options but didn't work so I had to do this instead https://palantir.github.io/tslint/usage/rule-flags/
@Andarist Is there anything blocking this PR? I'm happy to address them 😄 |
What: #3075
Why: To fix inconsistent type from #3075
How: Reorganizing the
@emotion/utils
by moving the types to the proper package.Checklist:
I'm not able to fix the
constructor
issue. When I tried to convert it tointerface
/types
, it complains as it was either being merged toStyleSheet
DOM type or a duplicate name.