Skip to content

Commit

Permalink
Add speedy method to the TS type declaration of the sheet object avai…
Browse files Browse the repository at this point in the history
…lable on Emotion instances (#1848)

* Add sheet.speedy() type to StyleSheet

* Stylesheet.speedy is optional

* No semicolon for consistency

* Add speedy method to the TS type declaration of the sheet object available on Emotion instance

* Add changeset

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
  • Loading branch information
osdiab and Andarist authored Jul 8, 2020
1 parent 58dc08a commit 6d32d82
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/young-sloths-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@emotion/css': patch
---

Added `speedy` method to the TS type declaration of the `sheet` object available on Emotion instances. In addition to that - `StyleSheet` type is no longer exported from this package and instead `CSSStyleSheet` is available now. The `StyleSheet` type might still be imported from `@emotion/sheet`, but it has no `speedy` method and thus it's not the same as what is available in this package as `CSSStyleSheet`.
8 changes: 6 additions & 2 deletions packages/css/types/create-instance.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export {
CSSObject
} from '@emotion/serialize'

export { EmotionCache, Options, StyleSheet }
export { EmotionCache, Options }

export interface ArrayClassNamesArg extends Array<ClassNamesArg> {}
export type ClassNamesArg =
Expand All @@ -23,6 +23,10 @@ export type ClassNamesArg =
| { [className: string]: boolean | null | undefined }
| ArrayClassNamesArg

export interface CSSStyleSheet extends StyleSheet {
speedy(value: boolean): void
}

export interface Emotion {
css(template: TemplateStringsArray, ...args: Array<CSSInterpolation>): string
css(...args: Array<CSSInterpolation>): string
Expand All @@ -39,7 +43,7 @@ export interface Emotion {
...args: Array<CSSInterpolation>
): string
keyframes(...args: Array<CSSInterpolation>): string
sheet: StyleSheet
sheet: CSSStyleSheet
cache: EmotionCache
merge(className: string): string
getRegisteredStyles(
Expand Down
2 changes: 1 addition & 1 deletion packages/css/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export {
EmotionCache,
CSSInterpolation,
CSSObject,
StyleSheet
CSSStyleSheet
} from './create-instance'

export const flush: Emotion['flush']
Expand Down

0 comments on commit 6d32d82

Please sign in to comment.