mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary:
This diff add support for promises. It wraps promise's type into a special type annotation.
#Facebook
Currently the shape of promises parsing is:
```
{
name: 'getValueWithPromise',
optional: false,
typeAnnotation: {
type: 'FunctionTypeAnnotation',
params: [
{
name: 'error',
typeAnnotation: {
type: 'BooleanTypeAnnotation',
},
},
],
returnTypeAnnotation: {
type: 'GenericTypeAnnotation',
typeId: {
hasteModuleName: 'NativeSampleTurboModule',
name: 'Promise',
},
typeParameters: [
{
type: 'StringTypeAnnotation',
},
],
},
returnTypeNameOverride: null,
},
rawTypeAnnotation: '(error: boolean) => Promise<string>',
documentation: null,
};
```
which is a bit unclear for me. I suggest sth way more easier:
```
{
"modules": {
"SampleTurboModule": {
"nativeModules": {
"SampleTurboModule": {
"properties": [
{
"name": "getValueWithPromise",
"typeAnnotation": {
"type": "FunctionTypeAnnotation",
"returnTypeAnnotation": {
"type": "PromiseTypeAnnotation",
"resolvingType": {
"type": "StringTypeAnnotation"
}
},
"params": [
{
"name": "error",
"typeAnnotation": {
"type": "BooleanTypeAnnotation"
}
}
]
}
}
]
}
}
}
}
}
```
However, I'd be happy to see some feedback / other solutions as well!
Reviewed By: TheSavior
Differential Revision: D16130941
fbshipit-source-id: c7dfd3f260b7c3028ce0e6208e96c62bd099ca7b