mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add support for optional methods
Summary: This diff adds an optional property. #Facebook Following this doc: https://our.intern.facebook.com/intern/wiki/React_Native/rctexport-interface-support/?vitals_event=wiki_click_navigation_link I suppose it's vital to support this property as well. However i don't know if it's really useful, so thus I made a separated diff for it. Reviewed By: TheSavior Differential Revision: D16121408 fbshipit-source-id: 15491575e999ee4fcddfd176f52d927789458061
This commit is contained in:
committed by
Facebook Github Bot
parent
929c5d7c10
commit
b848af3b08
@@ -172,6 +172,7 @@ export type FunctionTypeAnnotation = $ReadOnly<{|
|
||||
type: 'FunctionTypeAnnotation',
|
||||
params: $ReadOnlyArray<FunctionTypeAnnotationParam>,
|
||||
returnTypeAnnotation: FunctionTypeAnnotationReturn,
|
||||
optional: boolean,
|
||||
|}>;
|
||||
|
||||
export type MethodTypeShape = $ReadOnly<{|
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ import type {TurboModule} from '../RCTExport';
|
||||
import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
+passBool: (arg: boolean) => void;
|
||||
+passBool?: (arg: boolean) => void;
|
||||
+passNumber: (arg: number) => void;
|
||||
+passString: (arg: string) => void;
|
||||
}
|
||||
|
||||
+8
@@ -3336,6 +3336,7 @@ Object {
|
||||
Object {
|
||||
"name": "getArray",
|
||||
"typeAnnotation": Object {
|
||||
"optional": false,
|
||||
"params": Array [
|
||||
Object {
|
||||
"name": "arg",
|
||||
@@ -3374,6 +3375,7 @@ Object {
|
||||
Object {
|
||||
"name": "getArray",
|
||||
"typeAnnotation": Object {
|
||||
"optional": false,
|
||||
"params": Array [
|
||||
Object {
|
||||
"name": "arg",
|
||||
@@ -3412,6 +3414,7 @@ Object {
|
||||
Object {
|
||||
"name": "passBool",
|
||||
"typeAnnotation": Object {
|
||||
"optional": true,
|
||||
"params": Array [
|
||||
Object {
|
||||
"name": "arg",
|
||||
@@ -3429,6 +3432,7 @@ Object {
|
||||
Object {
|
||||
"name": "passNumber",
|
||||
"typeAnnotation": Object {
|
||||
"optional": false,
|
||||
"params": Array [
|
||||
Object {
|
||||
"name": "arg",
|
||||
@@ -3446,6 +3450,7 @@ Object {
|
||||
Object {
|
||||
"name": "passString",
|
||||
"typeAnnotation": Object {
|
||||
"optional": false,
|
||||
"params": Array [
|
||||
Object {
|
||||
"name": "arg",
|
||||
@@ -3478,6 +3483,7 @@ Object {
|
||||
Object {
|
||||
"name": "getArray",
|
||||
"typeAnnotation": Object {
|
||||
"optional": false,
|
||||
"params": Array [
|
||||
Object {
|
||||
"name": "arg",
|
||||
@@ -3575,6 +3581,7 @@ Object {
|
||||
Object {
|
||||
"name": "getNumber",
|
||||
"typeAnnotation": Object {
|
||||
"optional": false,
|
||||
"params": Array [
|
||||
Object {
|
||||
"name": "arg",
|
||||
@@ -3592,6 +3599,7 @@ Object {
|
||||
Object {
|
||||
"name": "getVoid",
|
||||
"typeAnnotation": Object {
|
||||
"optional": false,
|
||||
"params": Array [],
|
||||
"returnTypeAnnotation": Object {
|
||||
"type": "VoidTypeAnnotation",
|
||||
|
||||
@@ -222,6 +222,7 @@ function buildMethodSchema(
|
||||
type: 'FunctionTypeAnnotation',
|
||||
returnTypeAnnotation,
|
||||
params,
|
||||
optional: property.optional,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user