mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Make enum types annotation objects instead of literal strings and numbers (#47349)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47349 This is needed to be able to recurse into the literals and compare them. I'm primarily unsure if there is a problem representing doubles/floats as numbers instead of strings though. Changelog: [Internal] Reviewed By: makovkastar Differential Revision: D65284058 fbshipit-source-id: b2de9ed5fb7f079a432c94aaea69027863879909
This commit is contained in:
committed by
Facebook GitHub Bot
parent
96c2be8567
commit
fa8a25eb6b
@@ -406,6 +406,14 @@ struct Bridging<${enumName}> {
|
||||
};`;
|
||||
};
|
||||
|
||||
function getMemberValueAppearance(member: NativeModuleEnumMember['value']) {
|
||||
if (member.type === 'StringLiteralTypeAnnotation') {
|
||||
return `"${member.value}"`;
|
||||
} else {
|
||||
return member.value;
|
||||
}
|
||||
}
|
||||
|
||||
function generateEnum(
|
||||
hasteModuleName: string,
|
||||
origEnumName: string,
|
||||
@@ -417,9 +425,6 @@ function generateEnum(
|
||||
const nativeEnumMemberType: NativeEnumMemberValueType =
|
||||
memberType === 'StringTypeAnnotation' ? 'std::string' : 'int32_t';
|
||||
|
||||
const getMemberValueAppearance = (value: string | number) =>
|
||||
memberType === 'StringTypeAnnotation' ? `"${value}"` : `${value}`;
|
||||
|
||||
const fromCases =
|
||||
members
|
||||
.map(
|
||||
|
||||
Reference in New Issue
Block a user