Commit 4f0d295
fix(TypeScript): Allow readonly arrays in transform (#46310)
Summary:
Currently readonly arrays aren't allowed in components' style, but readonly objects are accepted. This becomes evident in such case:
```ts
import { View } from 'react-native';
interface AppProps {
transform: readonly ({ translateX: number } | { translateY: number })[];
shadowOffset: Readonly<{ width: number; height: number }>;
}
export default function App({ transform, shadowOffset }: AppProps) {
return (
<>
{/* TypeScript error with transform */}
<View style={{ transform }} />
{/* No errors with shadowOffset */}
<View style={{ shadowOffset }} />
</>
);
}
```
## Changelog:
[GENERAL] [FIXED] - Allow readonly array type for transform property
Pull Request resolved: #46310
Test Plan:
`yarn test-typescript`
I added relevant tests cases.
Reviewed By: robhogan
Differential Revision: D62140462
Pulled By: NickGerleman
fbshipit-source-id: 87374b0901ebc40cab48d442b61fe7a65711bc891 parent 5e6fed3 commit 4f0d295
2 files changed
Lines changed: 30 additions & 16 deletions
File tree
- packages/react-native
- Libraries/StyleSheet
- types/__typetests__
Lines changed: 17 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
200 | 202 | | |
201 | 203 | | |
202 | 204 | | |
| |||
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
0 commit comments