RN: Add RootTag to New Commands Codegen

Summary:
Adds support for `RootTag` in the new codegen for Native Component Commands.

Changelog: [Internal]

Reviewed By: TheSavior

Differential Revision: D21169371

fbshipit-source-id: 3b25433f3328e9c04cfe45bb176fc06d63559f14
This commit is contained in:
Tim Yung
2020-04-23 12:41:43 -07:00
committed by Facebook GitHub Bot
parent 310b0c3af5
commit 4d9fa4b08e
12 changed files with 150 additions and 15 deletions
@@ -153,7 +153,17 @@ function generatePropCasesString(
}
function getCommandArgJavaType(param, index) {
switch (param.typeAnnotation.type) {
const {typeAnnotation} = param;
switch (typeAnnotation.type) {
case 'ReservedFunctionValueTypeAnnotation':
switch (typeAnnotation.name) {
case 'RootTag':
return `args.getDouble(${index})`;
default:
(typeAnnotation.name: empty);
throw new Error(`Receieved invalid type: ${typeAnnotation.name}`);
}
case 'BooleanTypeAnnotation':
return `args.getBoolean(${index})`;
case 'DoubleTypeAnnotation':
@@ -165,8 +175,8 @@ function getCommandArgJavaType(param, index) {
case 'StringTypeAnnotation':
return `args.getString(${index})`;
default:
(param.typeAnnotation.type: empty);
throw new Error('Receieved invalid typeAnnotation');
(typeAnnotation.type: empty);
throw new Error(`Receieved invalid type: ${typeAnnotation.type}`);
}
}