flow-api-translator 0.329.0 → 0.331.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,8 +12,16 @@ function analyzeFunctionReturn(func) {
12
12
  if (returnType != null) {
13
13
  return returnType;
14
14
  }
15
+ const voidType = _flowTransform.t.VoidTypeAnnotation();
15
16
  return _flowTransform.t.TypeAnnotation({
16
- typeAnnotation: _flowTransform.t.VoidTypeAnnotation()
17
+ typeAnnotation: func.async ? _flowTransform.t.GenericTypeAnnotation({
18
+ id: _flowTransform.t.Identifier({
19
+ name: 'Promise'
20
+ }),
21
+ typeParameters: _flowTransform.t.TypeParameterInstantiation({
22
+ params: [voidType]
23
+ })
24
+ }) : voidType
17
25
  });
18
26
  }
19
27
  function analyzeTypeDependencies(rootNode, context) {
@@ -12,8 +12,16 @@ function analyzeFunctionReturn(func) {
12
12
  if (returnType != null) {
13
13
  return returnType;
14
14
  }
15
+ const voidType = _flowTransform.t.VoidTypeAnnotation();
15
16
  return _flowTransform.t.TypeAnnotation({
16
- typeAnnotation: _flowTransform.t.VoidTypeAnnotation()
17
+ typeAnnotation: func.async ? _flowTransform.t.GenericTypeAnnotation({
18
+ id: _flowTransform.t.Identifier({
19
+ name: 'Promise'
20
+ }),
21
+ typeParameters: _flowTransform.t.TypeParameterInstantiation({
22
+ params: [voidType]
23
+ })
24
+ }) : voidType
17
25
  });
18
26
  }
19
27
  function analyzeTypeDependencies(rootNode, context) {
@@ -22,9 +22,19 @@ export function analyzeFunctionReturn(func: AFunction): TypeAnnotation {
22
22
  return returnType;
23
23
  }
24
24
 
25
- // We trust Flow has validated this function to only return void
25
+ const voidType = t.VoidTypeAnnotation();
26
+
27
+ // We trust Flow has validated this function to only return void. Async
28
+ // functions always wrap that return value in a Promise.
26
29
  // $FlowFixMe[incompatible-type]
27
- return t.TypeAnnotation({typeAnnotation: t.VoidTypeAnnotation()});
30
+ return t.TypeAnnotation({
31
+ typeAnnotation: func.async
32
+ ? t.GenericTypeAnnotation({
33
+ id: t.Identifier({name: 'Promise'}),
34
+ typeParameters: t.TypeParameterInstantiation({params: [voidType]}),
35
+ })
36
+ : voidType,
37
+ });
28
38
  }
29
39
 
30
40
  export function analyzeTypeDependencies(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flow-api-translator",
3
- "version": "0.329.0",
3
+ "version": "0.331.0",
4
4
  "description": "Toolkit for creating Flow and TypeScript compatible libraries from Flow source code.",
5
5
  "homepage": "https://flow.org",
6
6
  "license": "MIT",
@@ -14,10 +14,10 @@
14
14
  "@typescript-eslint/parser": "8.38.0",
15
15
  "@typescript-eslint/visitor-keys": "8.38.0",
16
16
  "flow-enums-runtime": "^0.0.6",
17
- "flow-eslint": "0.329.0",
18
- "flow-estree": "0.329.0",
19
- "flow-parser": "0.329.0",
20
- "flow-transform": "0.329.0",
17
+ "flow-eslint": "0.331.0",
18
+ "flow-estree": "0.331.0",
19
+ "flow-parser": "0.331.0",
20
+ "flow-transform": "0.331.0",
21
21
  "typescript": "5.3.2"
22
22
  },
23
23
  "peerDependencies": {