mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
RN: Follow-up Format w/ Prettier v2.x
Summary: When I upgraded React Native to Prettier v2.x, I removed `format` from a few files to reduce the number of changes. This is a follow-up to bring back `format` and fix any remaining issues. Changelog: [Internal] Reviewed By: zertosh Differential Revision: D32287259 fbshipit-source-id: 37ea6d2c973b1db5d37c46d73675bdf436fb9a9d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
cf763cdf81
commit
10f9ab4d69
+17
-25
@@ -5,7 +5,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict
|
||||
* @noformat
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -100,10 +100,8 @@ function translateFunctionParamToJavaType(
|
||||
imports: Set<string>,
|
||||
): string {
|
||||
const {optional, typeAnnotation: nullableTypeAnnotation} = param;
|
||||
const [
|
||||
typeAnnotation,
|
||||
nullable,
|
||||
] = unwrapNullable<NativeModuleParamTypeAnnotation>(nullableTypeAnnotation);
|
||||
const [typeAnnotation, nullable] =
|
||||
unwrapNullable<NativeModuleParamTypeAnnotation>(nullableTypeAnnotation);
|
||||
const isRequired = !optional && !nullable;
|
||||
|
||||
function wrapIntoNullableIfNeeded(generatedType: string) {
|
||||
@@ -169,12 +167,10 @@ function translateFunctionReturnTypeToJavaType(
|
||||
resolveAlias: AliasResolver,
|
||||
imports: Set<string>,
|
||||
): string {
|
||||
const [
|
||||
returnTypeAnnotation,
|
||||
nullable,
|
||||
] = unwrapNullable<NativeModuleReturnTypeAnnotation>(
|
||||
nullableReturnTypeAnnotation,
|
||||
);
|
||||
const [returnTypeAnnotation, nullable] =
|
||||
unwrapNullable<NativeModuleReturnTypeAnnotation>(
|
||||
nullableReturnTypeAnnotation,
|
||||
);
|
||||
|
||||
function wrapIntoNullableIfNeeded(generatedType: string) {
|
||||
if (nullable) {
|
||||
@@ -234,12 +230,10 @@ function getFalsyReturnStatementFromReturnType(
|
||||
createErrorMessage: (typeName: string) => string,
|
||||
resolveAlias: AliasResolver,
|
||||
): string {
|
||||
const [
|
||||
returnTypeAnnotation,
|
||||
nullable,
|
||||
] = unwrapNullable<NativeModuleReturnTypeAnnotation>(
|
||||
nullableReturnTypeAnnotation,
|
||||
);
|
||||
const [returnTypeAnnotation, nullable] =
|
||||
unwrapNullable<NativeModuleReturnTypeAnnotation>(
|
||||
nullableReturnTypeAnnotation,
|
||||
);
|
||||
|
||||
let realTypeAnnotation = returnTypeAnnotation;
|
||||
if (realTypeAnnotation.type === 'TypeAliasTypeAnnotation') {
|
||||
@@ -288,9 +282,8 @@ function buildGetConstantsMethod(
|
||||
method: NativeModulePropertyShape,
|
||||
imports: Set<string>,
|
||||
): string {
|
||||
const [
|
||||
methodTypeAnnotation,
|
||||
] = unwrapNullable<NativeModuleFunctionTypeAnnotation>(method.typeAnnotation);
|
||||
const [methodTypeAnnotation] =
|
||||
unwrapNullable<NativeModuleFunctionTypeAnnotation>(method.typeAnnotation);
|
||||
if (
|
||||
methodTypeAnnotation.returnTypeAnnotation.type === 'ObjectTypeAnnotation'
|
||||
) {
|
||||
@@ -405,11 +398,10 @@ module.exports = {
|
||||
return buildGetConstantsMethod(method, imports);
|
||||
}
|
||||
|
||||
const [
|
||||
methodTypeAnnotation,
|
||||
] = unwrapNullable<NativeModuleFunctionTypeAnnotation>(
|
||||
method.typeAnnotation,
|
||||
);
|
||||
const [methodTypeAnnotation] =
|
||||
unwrapNullable<NativeModuleFunctionTypeAnnotation>(
|
||||
method.typeAnnotation,
|
||||
);
|
||||
|
||||
// Handle return type
|
||||
const translatedReturnType = translateFunctionReturnTypeToJavaType(
|
||||
|
||||
Reference in New Issue
Block a user