mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
8d807dfbc3
Summary: Previously, all our type annotations contained a `nullable` property. This diff removes that property from all our NativeModule type annotations, and instead introduces a `NullableTypeAnnotation`. **Some Benefits:** - In all our serialization functions, we use Flow exhaustive checking to ensure that all type-annotations can be serialized. Since nullability is now recorded as a type annotation, Flow will ensure we always explicitly handle nullability. Previously, with nullability as a property, we could ignore it without any feedback from flow. - This aligns the NativeModule schema with the ESTree spec. - After this diff, we're one step closer to sharing type annotations with Codegen's schema. Many NativeModule type annotations now have the same shape as their Codegen counterparts. They will be merged in a subsequent diff. **Downsides:** - If you want to check whether a type annotation is of type `T`, you have to remember to unwrap the type annotation *yourself*. Flow won't warn you if you forget to unwrap the type, which can lead to incomplete handling to nullable types in our generators. - When you're creating type annotations in code, previously, you *had* to specify nullability, since it was a property on all type annotation objects. Now, it's very possible for you to forget to wrap the type annotation, which will just lead to nullability bugs. **Notes:** - In the scheam, exported type annotations are *always* required. They can be made nullable using the new `Nullable` genric type. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D24026887 fbshipit-source-id: 9e71e2c6102dc506824403dbb712488ca8507d08