Fix support for objects' types defined in file

Summary: By my mistake previosly it was not poossible to return object defined somewhere in file or return promise containing that object. I changed it to consider value which might be takes from `types` object.

Reviewed By: rickhanlonii

Differential Revision: D16283800

fbshipit-source-id: e9b0ad85b921022732ea0a11db9b58115e87aaa5
This commit is contained in:
Michał Osadnik 2019-07-17 06:13:28 -07:00 коммит произвёл Facebook Github Bot
Родитель 6c7f3afee2
Коммит d1931344b0
3 изменённых файлов: 26 добавлений и 1 удалений

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

@ -358,10 +358,12 @@ import type {TurboModule} from '../RCTExport';
import * as TurboModuleRegistry from '../TurboModuleRegistry';
export type String = string
export type SomeObj = {| a: string |};
export interface Spec extends TurboModule {
+getValueWithPromise: () => Promise<string>;
+getValueWithPromiseDefinedSomewhereElse: () => Promise<String>;
+getValueWithPromiseObjDefinedSomewhereElse: () => Promise<SomeObj>;
}
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');

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

@ -680,6 +680,29 @@ Object {
"type": "FunctionTypeAnnotation",
},
},
Object {
"name": "getValueWithPromiseObjDefinedSomewhereElse",
"typeAnnotation": Object {
"optional": false,
"params": Array [],
"returnTypeAnnotation": Object {
"resolvedType": Object {
"properties": Array [
Object {
"name": "a",
"optional": false,
"typeAnnotation": Object {
"type": "StringTypeAnnotation",
},
},
],
"type": "ObjectTypeAnnotation",
},
"type": "GenericPromiseTypeAnnotation",
},
"type": "FunctionTypeAnnotation",
},
},
],
},
},

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

@ -290,7 +290,7 @@ function getReturnTypeAnnotation(
type: 'ObjectTypeAnnotation',
properties: getObjectProperties(
methodName,
returnType,
typeAnnotation,
'returning value',
types,
),