Skip to content

Commit

Permalink
Change Array to ReadonlyArray in CSS type declarations (#3141)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cerber-Ursi committed Dec 23, 2023
1 parent 1c60314 commit 45c440f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-pugs-applaud.md
@@ -0,0 +1,5 @@
---
'@emotion/serialize': patch
---

Replace arrays with readonly arrays in CSS type definitions, following changes in `csstype`
6 changes: 4 additions & 2 deletions packages/react/types/tests-css.tsx
Expand Up @@ -32,8 +32,10 @@ css`
// $ExpectError
css(() => 'height: 300px;')

// $ExpectError
css`
position: relative;
flexgrow: ${() => 20};
flexgrow: ${
// $ExpectError
() => 20
};
`
5 changes: 3 additions & 2 deletions packages/serialize/types/index.d.ts
Expand Up @@ -10,12 +10,13 @@ export type CSSProperties = CSS.PropertiesFallback<number | string>
export type CSSPropertiesWithMultiValues = {
[K in keyof CSSProperties]:
| CSSProperties[K]
| Array<Extract<CSSProperties[K], string>>
| ReadonlyArray<Extract<CSSProperties[K], string>>
}

export type CSSPseudos = { [K in CSS.Pseudos]?: CSSObject }

export interface ArrayCSSInterpolation extends Array<CSSInterpolation> {}
export interface ArrayCSSInterpolation
extends ReadonlyArray<CSSInterpolation> {}

export type InterpolationPrimitive =
| null
Expand Down
6 changes: 5 additions & 1 deletion packages/serialize/types/tests.ts
Expand Up @@ -48,8 +48,12 @@ serializeStyles({}, {})

let cssObject: CSSObject = {
fontWeight: 400,
background: ['red'],
otherProp: ['some-value'],
':hover': {
fontWeight: 700
fontWeight: 700,
background: ['red'] as const,
otherProp: ['some-value'] as const
}
}

Expand Down

0 comments on commit 45c440f

Please sign in to comment.