Skip to content

Commit 45c440f

Browse files
authored
Change Array to ReadonlyArray in CSS type declarations (#3141)
1 parent 1c60314 commit 45c440f

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

.changeset/warm-pugs-applaud.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@emotion/serialize': patch
3+
---
4+
5+
Replace arrays with readonly arrays in CSS type definitions, following changes in `csstype`

packages/react/types/tests-css.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ css`
3232
// $ExpectError
3333
css(() => 'height: 300px;')
3434

35-
// $ExpectError
3635
css`
3736
position: relative;
38-
flexgrow: ${() => 20};
37+
flexgrow: ${
38+
// $ExpectError
39+
() => 20
40+
};
3941
`

packages/serialize/types/index.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ export type CSSProperties = CSS.PropertiesFallback<number | string>
1010
export type CSSPropertiesWithMultiValues = {
1111
[K in keyof CSSProperties]:
1212
| CSSProperties[K]
13-
| Array<Extract<CSSProperties[K], string>>
13+
| ReadonlyArray<Extract<CSSProperties[K], string>>
1414
}
1515

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

18-
export interface ArrayCSSInterpolation extends Array<CSSInterpolation> {}
18+
export interface ArrayCSSInterpolation
19+
extends ReadonlyArray<CSSInterpolation> {}
1920

2021
export type InterpolationPrimitive =
2122
| null

packages/serialize/types/tests.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ serializeStyles({}, {})
4848

4949
let cssObject: CSSObject = {
5050
fontWeight: 400,
51+
background: ['red'],
52+
otherProp: ['some-value'],
5153
':hover': {
52-
fontWeight: 700
54+
fontWeight: 700,
55+
background: ['red'] as const,
56+
otherProp: ['some-value'] as const
5357
}
5458
}
5559

0 commit comments

Comments
 (0)