mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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:
1 parent
cb7f3f4499
commit
00cfb0f919
21 files changed
+195
-199
No files matched your search
Vendored
+10
-10
@@ -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: {...}.`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user