Omit null process/diff functions from native VC attributes

Summary:
## Rationale
- **Consistency with Static View Configs**: In Static View Configs, if there isn't a diff or process function, we do not generate a property for it.
- **Type-safety**: The [Flow type for attributes](https://fburl.com/code/tafncg5c), doesn't allow null diff/process functions.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D32152924

fbshipit-source-id: 4156158c5fe09868feec1a0c55aa411d2bd72a27
This commit is contained in:
Ramanpreet Nara 2021-11-03 15:56:41 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 43c38cdc8e
Коммит d03b4f9ee2
1 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -63,8 +63,18 @@ function getNativeComponentAttributes(uiViewClassName: string): any {
const diff = getDifferForType(typeName);
const process = getProcessorForType(typeName);
// If diff or process == null, omit the corresponding property from the Attribute
// Why:
// 1. Consistency with AttributeType flow type
// 2. Consistency with Static View Configs, which omit the null properties
validAttributes[key] =
diff == null && process == null ? true : {diff, process};
diff == null
? process == null
? true
: {process}
: process == null
? {diff}
: {diff, process};
}
// Unfortunately, the current setup declares style properties as top-level