mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
c16defaff2
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