mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
67b9628af5
Summary: Changelog: [General][Breaking] Native modules using the codegen now throw an error when called with `null` for optional but not nullable arguments. ## Context Right now, if you have a native module using the codegen with a method like this: ``` someMethod(value?: number): void; ``` And you call it like this: ``` NativeModule.someMethod(null); ``` The app doesn't throw an error, but it should because this method shouldn't accept `null` according to its type definition. ## Changes This modifies the codegen to only check for `undefined` in those cases, otherwise trying to cast the value to the expected type and failing if it's `null`. NOTE: this is technically a breaking change, but if people are using Flow or TypeScript in their projects they're very unlikely to hit this case, because they would've complained if you tried to pass `null` in these cases. Reviewed By: cipolleschi Differential Revision: D54206289 fbshipit-source-id: 58f2f2f3009d203b96189d3c66d1ae98a9e4fb36