-
-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
'@emotion/cache': minor | ||
'@emotion/css': minor | ||
'@emotion/react': minor | ||
'@emotion/serialize': minor | ||
'@emotion/server': minor | ||
'@emotion/utils': minor | ||
--- | ||
|
||
Reorganize @emotion/utils types |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,21 @@ css` | |
top: ${'20px'}; | ||
` | ||
|
||
// $ExpectType SerializedStyles | ||
css([{ display: null }]) | ||
|
||
// $ExpectType SerializedStyles | ||
css({ | ||
':hover': [{ color: 'green' }, { backgroundColor: 'yellow' }] | ||
}) | ||
|
||
// $ExpectType SerializedStyles | ||
css({ | ||
':hover': css` | ||
color: hotpink; | ||
` | ||
}) | ||
|
||
// $ExpectError | ||
css(() => 'height: 300px;') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. this There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
// Definitions by: Junyoung Clare Jang <https://github.com/Ailrun> | ||
// TypeScript Version: 2.8 | ||
|
||
import { RegisteredCache, SerializedStyles } from '@emotion/utils' | ||
import type { RegisteredCache } from '@emotion/cache' | ||
import * as CSS from 'csstype' | ||
|
||
export { RegisteredCache, SerializedStyles } | ||
export interface SerializedStyles { | ||
name: string | ||
styles: string | ||
map?: string | ||
next?: SerializedStyles | ||
} | ||
|
||
export type CSSProperties = CSS.PropertiesFallback<number | string> | ||
export type CSSPropertiesWithMultiValues = { | ||
[K in keyof CSSProperties]: | ||
| null | ||
| undefined | ||
| false | ||
Comment on lines
+16
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 When I used it and passed The 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 |
||
| 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Looks legit but I will have to reexamine this more closely later. |
||
|
||
export interface ArrayCSSInterpolation extends Array<CSSInterpolation> {} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
// Definitions by: Junyoung Clare Jang <https://github.com/Ailrun> | ||
// TypeScript Version: 2.2 | ||
import type { SerializedStyles as EmotionSerializedStyles } from '@emotion/serialize' | ||
import type { | ||
RegisteredCache as EmotionRegisteredCache, | ||
EmotionCache as EmotionStyleCache | ||
} from '@emotion/cache' | ||
|
||
/** @deprecated use `RegisteredCache` from `@emotion/cache` */ | ||
export interface RegisteredCache { | ||
[key: string]: string | ||
} | ||
|
||
/** @deprecated use `StyleSheet` from `@emotion/sheet` */ | ||
export interface StyleSheet { | ||
container: HTMLElement | ||
nonce?: string | ||
|
@@ -14,6 +21,7 @@ export interface StyleSheet { | |
tags: Array<HTMLStyleElement> | ||
} | ||
|
||
/** @deprecated use `EmotionCache` from `@emotion/cache` */ | ||
export interface EmotionCache { | ||
inserted: { | ||
[key: string]: string | true | ||
|
@@ -31,6 +39,7 @@ export interface EmotionCache { | |
): string | void | ||
} | ||
|
||
/** @deprecated use `SerializedStyles` from `@emotion/serialize` */ | ||
export interface SerializedStyles { | ||
name: string | ||
styles: string | ||
|
@@ -41,19 +50,19 @@ export interface SerializedStyles { | |
export const isBrowser: boolean | ||
|
||
export function getRegisteredStyles( | ||
registered: RegisteredCache, | ||
registered: EmotionRegisteredCache, | ||
registeredStyles: Array<string>, | ||
classNames: string | ||
): string | ||
|
||
export function registerStyles( | ||
cache: EmotionCache, | ||
serialized: SerializedStyles, | ||
cache: EmotionStyleCache, | ||
serialized: EmotionSerializedStyles, | ||
isStringTag: boolean | ||
): void | ||
|
||
export function insertStyles( | ||
cache: EmotionCache, | ||
serialized: SerializedStyles, | ||
cache: EmotionStyleCache, | ||
serialized: EmotionSerializedStyles, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
isStringTag: boolean | ||
): string | void |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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/ |
||
} | ||
} |
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