Skip to content

Commit 41f525c

Browse files
SamChou19815facebook-github-bot
authored andcommitted
Pre-suppress unsafe string key access errors in xplat/js (facebook#44221)
Summary: Pull Request resolved: facebook#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
1 parent 4928f44 commit 41f525c

File tree

22 files changed

+47
-7
lines changed

22 files changed

+47
-7
lines changed

packages/assets/path-support.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const ANDROID_BASE_DENSITY = 160;
2929
*/
3030
function getAndroidAssetSuffix(scale: number): string {
3131
if (scale.toString() in androidScaleSuffix) {
32+
// $FlowFixMe[invalid-computed-prop]
3233
return androidScaleSuffix[scale.toString()];
3334
}
3435
// NOTE: Android Gradle Plugin does not fully support the nnndpi format.

packages/react-native-codegen/src/generators/TypeUtils/Java/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const objectTypeForPrimitiveType = {
1919
function wrapOptional(type: string, isRequired: boolean): string {
2020
return isRequired
2121
? type
22-
: `@Nullable ${objectTypeForPrimitiveType[type] ?? type}`;
22+
: // $FlowFixMe[invalid-computed-prop]
23+
`@Nullable ${objectTypeForPrimitiveType[type] ?? type}`;
2324
}
2425

2526
module.exports = {

packages/react-native-codegen/src/generators/__tests__/RNCodegen-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ describe('RNCodegen.generate', () => {
5454

5555
let expectedPath = path.join(
5656
outputDirectory,
57+
// $FlowFixMe[invalid-computed-prop]
5758
expectedPaths[receivedBasename],
5859
);
5960
expect(receivedDir).toEqual(expectedPath);

packages/react-native-codegen/src/generators/components/ComponentsProviderUtils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function generateSupportedApplePlatformsMacro(
3939
const compilerMacroString = Object.keys(supportedPlatformsMap)
4040
.reduce((acc: string[], platform) => {
4141
if (!supportedPlatformsMap[platform]) {
42+
// $FlowFixMe[invalid-computed-prop]
4243
return [...acc, `!${APPLE_PLATFORMS_MACRO_MAP[platform]}`];
4344
}
4445
return acc;

packages/react-native-codegen/src/parsers/error-utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ function throwIfPropertyValueTypeIsUnsupported(
186186
type: string,
187187
) {
188188
const invalidPropertyValueType =
189+
// $FlowFixMe[invalid-computed-prop]
189190
UnsupportedObjectPropertyTypeToInvalidPropertyValueTypeMap[type];
190191

191192
throw new UnsupportedObjectPropertyValueTypeAnnotationParserError(
@@ -245,6 +246,7 @@ function throwIfArrayElementTypeAnnotationIsUnsupported(
245246
hasteModuleName,
246247
flowElementType,
247248
flowArrayType,
249+
// $FlowFixMe[invalid-computed-prop]
248250
TypeMap[type],
249251
);
250252
}

packages/react-native-codegen/src/parsers/parsers-primitives.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ function emitCommonTypes(
603603
typeAnnotation.type,
604604
);
605605

606+
// $FlowFixMe[invalid-computed-prop]
606607
const simpleEmitter = typeMap[typeAnnotationName];
607608
if (simpleEmitter) {
608609
return simpleEmitter(nullable);
@@ -611,6 +612,7 @@ function emitCommonTypes(
611612
const genericTypeAnnotationName =
612613
parser.getTypeAnnotationName(typeAnnotation);
613614

615+
// $FlowFixMe[invalid-computed-prop]
614616
const emitter = typeMap[genericTypeAnnotationName];
615617
if (!emitter) {
616618
return null;

packages/react-native/Libraries/Animated/NativeAnimatedHelper.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,18 +455,22 @@ function addWhitelistedInterpolationParam(param: string): void {
455455
}
456456

457457
function isSupportedColorStyleProp(prop: string): boolean {
458+
// $FlowFixMe[invalid-computed-prop]
458459
return SUPPORTED_COLOR_STYLES[prop] === true;
459460
}
460461

461462
function isSupportedStyleProp(prop: string): boolean {
463+
// $FlowFixMe[invalid-computed-prop]
462464
return SUPPORTED_STYLES[prop] === true;
463465
}
464466

465467
function isSupportedTransformProp(prop: string): boolean {
468+
// $FlowFixMe[invalid-computed-prop]
466469
return SUPPORTED_TRANSFORMS[prop] === true;
467470
}
468471

469472
function isSupportedInterpolationParam(param: string): boolean {
473+
// $FlowFixMe[invalid-computed-prop]
470474
return SUPPORTED_INTERPOLATION_PARAMS[param] === true;
471475
}
472476

packages/react-native/Libraries/Animated/useAnimatedProps.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
141141
const events = [];
142142

143143
for (const propName in props) {
144+
// $FlowFixMe[invalid-computed-prop]
144145
const propValue = props[propName];
145146
if (propValue instanceof AnimatedEvent && propValue.__isNative) {
146147
propValue.__attach(target, propName);

packages/react-native/Libraries/BatchedBridge/MessageQueue.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ class MessageQueue {
424424
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`,
425425
);
426426
}
427+
// $FlowFixMe[invalid-computed-prop]
427428
if (!moduleMethods[method]) {
428429
invariant(
429430
false,

packages/react-native/Libraries/Image/ImageUtils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ export function convertObjectFitToResizeMode(objectFit: string): ResizeMode {
1717
fill: 'stretch',
1818
'scale-down': 'contain',
1919
};
20+
// $FlowFixMe[invalid-computed-prop]
2021
return objectFitMap[objectFit];
2122
}

0 commit comments

Comments
 (0)