mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Introduce ObjectTypeAnnotation utility type
Summary:
All throughout the Codegen schema, we re-declare the following shape:
```
{
type: 'ObjectTypeAnnotation',
properties: $ReadOnlyArray<{
name: string,
optional: boolean,
typeAnnotation: ...
}>
}
```
This diff introduces an `ObjectTypeAnnotation<T>` utility type and replaces those re-declarations with instantiations of this type.
**Motivation:** To reduce noise in the CodegenSchema. This should be a pure refactor, and shouldn't actually change any behaviour.
Changelog: [Internal]
Reviewed By: yungsters
Differential Revision: D24707963
fbshipit-source-id: 6b4eb711ddd041f3a041109ade5ad5644fb16924
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b9f6937288
commit
688caa0bdc
+8
-4
@@ -11,9 +11,10 @@
|
||||
'use strict';
|
||||
|
||||
import type {
|
||||
CommandTypeShape,
|
||||
NamedShape,
|
||||
CommandsTypeAnnotation,
|
||||
ComponentShape,
|
||||
PropTypeShape,
|
||||
PropTypeAnnotation,
|
||||
SchemaType,
|
||||
} from '../../CodegenSchema';
|
||||
const {
|
||||
@@ -47,7 +48,10 @@ function addNullable(imports) {
|
||||
imports.add('import androidx.annotation.Nullable;');
|
||||
}
|
||||
|
||||
function getJavaValueForProp(prop: PropTypeShape, imports): string {
|
||||
function getJavaValueForProp(
|
||||
prop: NamedShape<PropTypeAnnotation>,
|
||||
imports,
|
||||
): string {
|
||||
const typeAnnotation = prop.typeAnnotation;
|
||||
|
||||
switch (typeAnnotation.type) {
|
||||
@@ -153,7 +157,7 @@ function getCommandArgJavaType(param) {
|
||||
}
|
||||
|
||||
function getCommandArguments(
|
||||
command: CommandTypeShape,
|
||||
command: NamedShape<CommandsTypeAnnotation>,
|
||||
componentName: string,
|
||||
): string {
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user