A framework for building native applications using React
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: https://github.com/facebook/react-native/pull/46310
Test Plan:
`yarn test-typescript`
I added relevant tests cases.
Reviewed By: robhogan
Differential Revision: D62140462
Pulled By: NickGerleman
fbshipit-source-id: 87374b0901ebc40cab48d442b61fe7a65711bc89 T
Tomasz Żelawski committed
4f0d295e77c6035c41990b910801632fa1b88e07
Parent: 5e6fed3
Committed by Blake Friedman <blake.friedman@gmail.com>
on 9/30/2024, 2:53:47 PM