Skip to content
Snippets Groups Projects
Commit 4f0d295e authored by Tomasz Żelawski's avatar Tomasz Żelawski Committed by Blake Friedman
Browse files

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
parent 5e6fed36
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment