mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add LTI annotations to function params in xplat/js [1/2]
Summary: Add annotations to function parameters required for Flow's Local Type Inference project. This codemod prepares the codebase to match Flow's new typechecking algorithm. The new algorithm will make Flow more reliable and predicatable. Reviewed By: evanyeung Differential Revision: D37353648 fbshipit-source-id: e5a0c685ced85a8ff353d578b373f836b376bb28
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a7db8df207
commit
e7a4dbcefc
+11
-4
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
import type {CommandParamTypeAnnotation} from '../../CodegenSchema';
|
||||
|
||||
import type {
|
||||
NamedShape,
|
||||
@@ -170,7 +171,10 @@ function generatePropCasesString(
|
||||
}`;
|
||||
}
|
||||
|
||||
function getCommandArgJavaType(param, index) {
|
||||
function getCommandArgJavaType(
|
||||
param: NamedShape<CommandParamTypeAnnotation>,
|
||||
index: number,
|
||||
) {
|
||||
const {typeAnnotation} = param;
|
||||
|
||||
switch (typeAnnotation.type) {
|
||||
@@ -229,7 +233,7 @@ function generateCommandCasesString(
|
||||
return commandMethods;
|
||||
}
|
||||
|
||||
function getClassExtendString(component): string {
|
||||
function getClassExtendString(component: ComponentShape): string {
|
||||
const extendString = component.extendsProps
|
||||
.map(extendProps => {
|
||||
switch (extendProps.type) {
|
||||
@@ -251,7 +255,7 @@ function getClassExtendString(component): string {
|
||||
return extendString;
|
||||
}
|
||||
|
||||
function getDelegateImports(component) {
|
||||
function getDelegateImports(component: ComponentShape) {
|
||||
const imports = getImports(component, 'delegate');
|
||||
// The delegate needs ReadableArray for commands always.
|
||||
// The interface doesn't always need it
|
||||
@@ -265,7 +269,10 @@ function getDelegateImports(component) {
|
||||
return imports;
|
||||
}
|
||||
|
||||
function generateMethods(propsString, commandsString): string {
|
||||
function generateMethods(
|
||||
propsString: string,
|
||||
commandsString: null | string,
|
||||
): string {
|
||||
return [
|
||||
PropSetterTemplate({propCases: propsString}),
|
||||
commandsString != null
|
||||
|
||||
Reference in New Issue
Block a user