Remove pipes from Object literal Flow types

Summary:
## Changes
{| ... |} -> { ... }

**Motivation:** In Flow, object literals are exact by default. So, there's no need for the pipes. Also: Now, the syntax for object literals is consistent across react-native-codegen.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D24774771

fbshipit-source-id: 24ceb6f5876122aa8ad9e08c7e903215864ad6f5
This commit is contained in:
Ramanpreet Nara authored and Facebook GitHub Bot committed 2020-11-06 16:24:44 -08:00
1 parent cb7f3f4499
commit 00cfb0f919
21 files changed
+195 -199

No files matched your search

@@ -32,16 +32,16 @@ const ProtocolMethodTemplate = ({
returnObjCType,
methodName,
params,
}: $ReadOnly<{|
}: $ReadOnly<{
returnObjCType: string,
methodName: string,
params: string,
|}>) => `- (${returnObjCType})${methodName}${params};`;
}>) => `- (${returnObjCType})${methodName}${params};`;
export type StructParameterRecord = $ReadOnly<{|
export type StructParameterRecord = $ReadOnly<{
paramIndex: number,
structName: string,
|}>;
}>;
type ReturnJSType =
| 'VoidKind'
@@ -51,14 +51,14 @@ type ReturnJSType =
| 'NumberKind'
| 'StringKind';
export type MethodSerializationOutput = $ReadOnly<{|
export type MethodSerializationOutput = $ReadOnly<{
methodName: string,
protocolMethod: string,
selector: string,
structParamRecords: $ReadOnlyArray<StructParameterRecord>,
returnJSType: ReturnJSType,
argCount: number,
|}>;
}>;
function serializeMethod(
hasteModuleName: string,
@@ -79,7 +79,7 @@ function serializeMethod(
);
}
const methodParams: Array<{|paramName: string, objCType: string|}> = [];
const methodParams: Array<{paramName: string, objCType: string}> = [];
const structParamRecords: Array<StructParameterRecord> = [];
params.forEach((param, index) => {
@@ -183,7 +183,7 @@ function getParamObjCType(
structName: string,
structCollector: StructCollector,
resolveAlias: AliasResolver,
): $ReadOnly<{|objCType: string, isStruct: boolean|}> {
): $ReadOnly<{objCType: string, isStruct: boolean}> {
const {name: paramName, typeAnnotation: nullableTypeAnnotation} = param;
const [typeAnnotation, nullable] = unwrapNullable(nullableTypeAnnotation);
const notRequired = param.optional || nullable;
@@ -215,7 +215,7 @@ function getParamObjCType(
*
* For example:
* Array<number> => NSArray<NSNumber *>
* type Animal = {||};
* type Animal = {};
* Array<Animal> => NSArray<JS::NativeSampleTurboModule::Animal *>, etc.
*/
return notStruct(wrapIntoNullableIfNeeded('NSArray *'));
@@ -398,7 +398,7 @@ function serializeConstantsProtocolMethods(
const {returnTypeAnnotation} = propertyTypeAnnotation;
if (returnTypeAnnotation.type !== 'ObjectTypeAnnotation') {
throw new Error(
`${hasteModuleName}.getConstants() may only return an object literal: {|...|}.`,
`${hasteModuleName}.getConstants() may only return an object literal: {...}.`,
);
}