Pre-suppress unsafe string key access errors in xplat/js (#44221)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44221

This diff pre-suppresses errors of the following pattern, to prepare for the next Flow release.

```
declare const obj: {foo: string};
declare const key: string;
obj[key]; // error: invalid-computed-prop
```

Changelog: [Internal]

Reviewed By: alexmckenley

Differential Revision: D56477899

fbshipit-source-id: 5676b8685bd3157a519fe433cfce0fa28e003502
This commit is contained in:
Sam Zhou
2024-04-23 11:36:14 -07:00
committed by Facebook GitHub Bot
parent 4928f44f70
commit 41f525ccae
22 changed files with 47 additions and 7 deletions
@@ -55,6 +55,7 @@ function stringify(obj: mixed): string {
return Object.keys(value ?? {})
.sort()
.reduce((sorted: {[key: string]: mixed}, key: string) => {
// $FlowFixMe[invalid-computed-prop]
sorted[key] = (value ?? {})[key];
return sorted;
}, {});