flow-api-translator 0.16.0 → 0.17.1
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.
package/dist/flowDefToTSDef.js
CHANGED
|
@@ -3027,6 +3027,8 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3027
3027
|
TypeOperator(node) {
|
|
3028
3028
|
switch (node.operator) {
|
|
3029
3029
|
case 'renders':
|
|
3030
|
+
case 'renders?':
|
|
3031
|
+
case 'renders*':
|
|
3030
3032
|
{
|
|
3031
3033
|
const hasReactImport = isReactImport(node, 'React');
|
|
3032
3034
|
return {
|
|
@@ -3330,9 +3330,11 @@ const getTransforms = (
|
|
|
3330
3330
|
typeAnnotation: transformTypeAnnotationType(node.argument),
|
|
3331
3331
|
};
|
|
3332
3332
|
},
|
|
3333
|
-
TypeOperator(node: FlowESTree.
|
|
3333
|
+
TypeOperator(node: FlowESTree.RendersType): TSESTree.TypeNode {
|
|
3334
3334
|
switch (node.operator) {
|
|
3335
|
-
case 'renders':
|
|
3335
|
+
case 'renders':
|
|
3336
|
+
case 'renders?':
|
|
3337
|
+
case 'renders*': {
|
|
3336
3338
|
const hasReactImport = isReactImport(node, 'React');
|
|
3337
3339
|
return {
|
|
3338
3340
|
type: 'TSTypeReference',
|
package/dist/flowToFlowDef.js
CHANGED
|
@@ -334,6 +334,12 @@ function convertStatement(stmt, context) {
|
|
|
334
334
|
|
|
335
335
|
function convertExpressionToTypeAnnotation(expr, context) {
|
|
336
336
|
switch (expr.type) {
|
|
337
|
+
case 'AsExpression':
|
|
338
|
+
{
|
|
339
|
+
const [resultExpr, deps] = convertAsExpression(expr, context);
|
|
340
|
+
return [resultExpr, deps];
|
|
341
|
+
}
|
|
342
|
+
|
|
337
343
|
case 'TypeCastExpression':
|
|
338
344
|
{
|
|
339
345
|
const [resultExpr, deps] = convertTypeCastExpression(expr, context);
|
|
@@ -1009,6 +1015,10 @@ function convertOpaqueType(opaqueType, context) {
|
|
|
1009
1015
|
}), [...typeParamsDeps, ...supertypeDeps]];
|
|
1010
1016
|
}
|
|
1011
1017
|
|
|
1018
|
+
function convertAsExpression(asExpression, context) {
|
|
1019
|
+
return convertTypeAnnotationType(asExpression.typeAnnotation, asExpression, context);
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1012
1022
|
function convertTypeCastExpression(typeCast, context) {
|
|
1013
1023
|
return convertTypeAnnotation(typeCast.typeAnnotation, typeCast, context);
|
|
1014
1024
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import type {
|
|
14
14
|
AFunction,
|
|
15
|
+
AsExpression,
|
|
15
16
|
BindingName,
|
|
16
17
|
ClassBody,
|
|
17
18
|
ClassDeclaration,
|
|
@@ -54,6 +55,7 @@ import type {
|
|
|
54
55
|
TypeAnnotation,
|
|
55
56
|
TypeAnnotationType,
|
|
56
57
|
TypeCastExpression,
|
|
58
|
+
RendersType,
|
|
57
59
|
TypeParameterDeclaration,
|
|
58
60
|
TypeParameterInstantiation,
|
|
59
61
|
VariableDeclaration,
|
|
@@ -418,6 +420,10 @@ function convertExpressionToTypeAnnotation(
|
|
|
418
420
|
context: TranslationContext,
|
|
419
421
|
): TranslatedResult<TypeAnnotationType> {
|
|
420
422
|
switch (expr.type) {
|
|
423
|
+
case 'AsExpression': {
|
|
424
|
+
const [resultExpr, deps] = convertAsExpression(expr, context);
|
|
425
|
+
return [resultExpr, deps];
|
|
426
|
+
}
|
|
421
427
|
case 'TypeCastExpression': {
|
|
422
428
|
const [resultExpr, deps] = convertTypeCastExpression(expr, context);
|
|
423
429
|
return [resultExpr, deps];
|
|
@@ -1108,7 +1114,7 @@ function convertComponentDeclaration(
|
|
|
1108
1114
|
}
|
|
1109
1115
|
|
|
1110
1116
|
return [
|
|
1111
|
-
asDetachedNode<
|
|
1117
|
+
asDetachedNode<RendersType>(rendersType),
|
|
1112
1118
|
analyzeTypeDependencies(rendersType, context),
|
|
1113
1119
|
];
|
|
1114
1120
|
})();
|
|
@@ -1403,6 +1409,17 @@ function convertOpaqueType(
|
|
|
1403
1409
|
];
|
|
1404
1410
|
}
|
|
1405
1411
|
|
|
1412
|
+
function convertAsExpression(
|
|
1413
|
+
asExpression: AsExpression,
|
|
1414
|
+
context: TranslationContext,
|
|
1415
|
+
): TranslatedResult<TypeAnnotationType> {
|
|
1416
|
+
return convertTypeAnnotationType(
|
|
1417
|
+
asExpression.typeAnnotation,
|
|
1418
|
+
asExpression,
|
|
1419
|
+
context,
|
|
1420
|
+
);
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1406
1423
|
function convertTypeCastExpression(
|
|
1407
1424
|
typeCast: TypeCastExpression,
|
|
1408
1425
|
context: TranslationContext,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flow-api-translator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "Toolkit for creating Flow and TypeScript compatible libraries from Flow source code.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"@babel/code-frame": "^7.16.0",
|
|
13
13
|
"@typescript-eslint/visitor-keys": "^5.42.0",
|
|
14
14
|
"flow-enums-runtime": "^0.0.6",
|
|
15
|
-
"hermes-eslint": "0.
|
|
16
|
-
"hermes-estree": "0.
|
|
17
|
-
"hermes-parser": "0.
|
|
18
|
-
"hermes-transform": "0.
|
|
15
|
+
"hermes-eslint": "0.17.1",
|
|
16
|
+
"hermes-estree": "0.17.1",
|
|
17
|
+
"hermes-parser": "0.17.1",
|
|
18
|
+
"hermes-transform": "0.17.1"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"prettier": "^3.0.0 || ^2.7.1"
|