Improve error when using mutable object as prop

Summary:
I was trying to add an object property to my ViewManager and got a really opaque error (and I almost thought Objects weren't supported by the codegen) until I realized it expected the object to wrapped in a $ReadOnly type.

Changelog: [Internal] Improved error in codegen

Reviewed By: mdvacca

Differential Revision: D34006557

fbshipit-source-id: b3ab15a40cb66fdcd377f4e68df92060498e8e7f
This commit is contained in:
Pieter De Baets 2022-02-07 08:17:39 -08:00 коммит произвёл Facebook GitHub Bot
Родитель 31a92b008d
Коммит b0bae21249
1 изменённых файлов: 4 добавлений и 0 удалений

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

@ -319,6 +319,10 @@ function getTypeAnnotation(
`Unsupported union type for "${name}", received "${unionType}"`,
);
}
case 'ObjectTypeAnnotation':
throw new Error(
`Cannot use "${type}" type annotation for "${name}": object types must be declared using $ReadOnly<>`,
);
case 'NumberTypeAnnotation':
throw new Error(
`Cannot use "${type}" type annotation for "${name}": must use a specific numeric type like Int32, Double, or Float`,