flow-api-translator 0.34.0 → 0.35.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.
package/dist/flowDefToTSDef.js
CHANGED
|
@@ -3120,7 +3120,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3120
3120
|
|
|
3121
3121
|
ObjectTypeAnnotation(node) {
|
|
3122
3122
|
if (node.properties.length === 1 && node.properties[0].type === 'ObjectTypeMappedTypeProperty') {
|
|
3123
|
-
var _prop$variance;
|
|
3123
|
+
var _prop$variance, _prop$variance2;
|
|
3124
3124
|
|
|
3125
3125
|
// Mapped Object Object types must not have other object properties.
|
|
3126
3126
|
const prop = node.properties[0];
|
|
@@ -3145,7 +3145,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3145
3145
|
name: prop.keyTparam.name
|
|
3146
3146
|
},
|
|
3147
3147
|
constraint: transformTypeAnnotationType(prop.sourceType),
|
|
3148
|
-
readonly: ((_prop$variance = prop.variance) == null ? void 0 : _prop$variance.kind) === 'plus',
|
|
3148
|
+
readonly: ((_prop$variance = prop.variance) == null ? void 0 : _prop$variance.kind) === 'plus' || ((_prop$variance2 = prop.variance) == null ? void 0 : _prop$variance2.kind) === 'readonly',
|
|
3149
3149
|
optional: prop.optional === 'Optional',
|
|
3150
3150
|
typeAnnotation: transformTypeAnnotationType(prop.propType),
|
|
3151
3151
|
nameType: null
|
|
@@ -3366,10 +3366,10 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3366
3366
|
},
|
|
3367
3367
|
|
|
3368
3368
|
ObjectTypeIndexer(node) {
|
|
3369
|
-
var _node$
|
|
3369
|
+
var _node$variance3, _node$variance4;
|
|
3370
3370
|
|
|
3371
3371
|
if (node.key.type === 'GenericTypeAnnotation') {
|
|
3372
|
-
var _node$variance;
|
|
3372
|
+
var _node$variance, _node$variance2;
|
|
3373
3373
|
|
|
3374
3374
|
const ident = node.key.id.type === 'Identifier' ? node.key.id : node.key.id.id;
|
|
3375
3375
|
return {
|
|
@@ -3391,7 +3391,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3391
3391
|
loc: DUMMY_LOC
|
|
3392
3392
|
}
|
|
3393
3393
|
},
|
|
3394
|
-
readonly: ((_node$variance = node.variance) == null ? void 0 : _node$variance.kind) === 'plus',
|
|
3394
|
+
readonly: ((_node$variance = node.variance) == null ? void 0 : _node$variance.kind) === 'plus' || ((_node$variance2 = node.variance) == null ? void 0 : _node$variance2.kind) === 'readonly',
|
|
3395
3395
|
static: node.static,
|
|
3396
3396
|
typeAnnotation: {
|
|
3397
3397
|
type: 'TSTypeAnnotation',
|
|
@@ -3414,7 +3414,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3414
3414
|
typeAnnotation: transformTypeAnnotationType(node.key)
|
|
3415
3415
|
}
|
|
3416
3416
|
}],
|
|
3417
|
-
readonly: ((_node$
|
|
3417
|
+
readonly: ((_node$variance3 = node.variance) == null ? void 0 : _node$variance3.kind) === 'plus' || ((_node$variance4 = node.variance) == null ? void 0 : _node$variance4.kind) === 'readonly',
|
|
3418
3418
|
static: node.static,
|
|
3419
3419
|
typeAnnotation: {
|
|
3420
3420
|
type: 'TSTypeAnnotation',
|
|
@@ -3425,7 +3425,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3425
3425
|
},
|
|
3426
3426
|
|
|
3427
3427
|
ObjectTypeProperty(node) {
|
|
3428
|
-
var _node$
|
|
3428
|
+
var _node$variance5, _node$variance6;
|
|
3429
3429
|
|
|
3430
3430
|
const [key, computed] = (() => {
|
|
3431
3431
|
if (node.key.type === 'Identifier' && node.key.name.startsWith('@@')) {
|
|
@@ -3509,7 +3509,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3509
3509
|
computed,
|
|
3510
3510
|
key,
|
|
3511
3511
|
optional: node.optional,
|
|
3512
|
-
readonly: ((_node$
|
|
3512
|
+
readonly: ((_node$variance5 = node.variance) == null ? void 0 : _node$variance5.kind) === 'plus' || ((_node$variance6 = node.variance) == null ? void 0 : _node$variance6.kind) === 'readonly',
|
|
3513
3513
|
static: node.static,
|
|
3514
3514
|
typeAnnotation: {
|
|
3515
3515
|
type: 'TSTypeAnnotation',
|
|
@@ -3631,7 +3631,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3631
3631
|
},
|
|
3632
3632
|
|
|
3633
3633
|
TupleTypeAnnotation(node) {
|
|
3634
|
-
const allReadOnly = node.elementTypes.length > 0 && node.elementTypes.every(element => element.type === 'TupleTypeLabeledElement' && element.variance != null && element.variance.kind === 'plus');
|
|
3634
|
+
const allReadOnly = node.elementTypes.length > 0 && node.elementTypes.every(element => element.type === 'TupleTypeLabeledElement' && element.variance != null && (element.variance.kind === 'plus' || element.variance.kind === 'readonly'));
|
|
3635
3635
|
const elems = node.elementTypes.map(element => {
|
|
3636
3636
|
switch (element.type) {
|
|
3637
3637
|
case 'TupleTypeLabeledElement':
|
|
@@ -3422,7 +3422,9 @@ const getTransforms = (
|
|
|
3422
3422
|
name: prop.keyTparam.name,
|
|
3423
3423
|
},
|
|
3424
3424
|
constraint: transformTypeAnnotationType(prop.sourceType),
|
|
3425
|
-
readonly:
|
|
3425
|
+
readonly:
|
|
3426
|
+
prop.variance?.kind === 'plus' ||
|
|
3427
|
+
prop.variance?.kind === 'readonly',
|
|
3426
3428
|
optional: prop.optional === 'Optional',
|
|
3427
3429
|
typeAnnotation: transformTypeAnnotationType(prop.propType),
|
|
3428
3430
|
nameType: null,
|
|
@@ -3699,7 +3701,9 @@ const getTransforms = (
|
|
|
3699
3701
|
loc: DUMMY_LOC,
|
|
3700
3702
|
},
|
|
3701
3703
|
},
|
|
3702
|
-
readonly:
|
|
3704
|
+
readonly:
|
|
3705
|
+
node.variance?.kind === 'plus' ||
|
|
3706
|
+
node.variance?.kind === 'readonly',
|
|
3703
3707
|
static: node.static,
|
|
3704
3708
|
typeAnnotation: {
|
|
3705
3709
|
type: 'TSTypeAnnotation',
|
|
@@ -3723,7 +3727,8 @@ const getTransforms = (
|
|
|
3723
3727
|
},
|
|
3724
3728
|
},
|
|
3725
3729
|
],
|
|
3726
|
-
readonly:
|
|
3730
|
+
readonly:
|
|
3731
|
+
node.variance?.kind === 'plus' || node.variance?.kind === 'readonly',
|
|
3727
3732
|
static: node.static,
|
|
3728
3733
|
typeAnnotation: {
|
|
3729
3734
|
type: 'TSTypeAnnotation',
|
|
@@ -3824,7 +3829,8 @@ const getTransforms = (
|
|
|
3824
3829
|
computed,
|
|
3825
3830
|
key,
|
|
3826
3831
|
optional: node.optional,
|
|
3827
|
-
readonly:
|
|
3832
|
+
readonly:
|
|
3833
|
+
node.variance?.kind === 'plus' || node.variance?.kind === 'readonly',
|
|
3828
3834
|
static: node.static,
|
|
3829
3835
|
typeAnnotation: {
|
|
3830
3836
|
type: 'TSTypeAnnotation',
|
|
@@ -3965,7 +3971,8 @@ const getTransforms = (
|
|
|
3965
3971
|
element =>
|
|
3966
3972
|
element.type === 'TupleTypeLabeledElement' &&
|
|
3967
3973
|
element.variance != null &&
|
|
3968
|
-
element.variance.kind === 'plus'
|
|
3974
|
+
(element.variance.kind === 'plus' ||
|
|
3975
|
+
element.variance.kind === 'readonly'),
|
|
3969
3976
|
);
|
|
3970
3977
|
const elems = node.elementTypes.map((element): TSESTree.TypeNode => {
|
|
3971
3978
|
switch (element.type) {
|
|
@@ -3120,7 +3120,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3120
3120
|
|
|
3121
3121
|
ObjectTypeAnnotation(node) {
|
|
3122
3122
|
if (node.properties.length === 1 && node.properties[0].type === 'ObjectTypeMappedTypeProperty') {
|
|
3123
|
-
var _prop$variance;
|
|
3123
|
+
var _prop$variance, _prop$variance2;
|
|
3124
3124
|
|
|
3125
3125
|
// Mapped Object Object types must not have other object properties.
|
|
3126
3126
|
const prop = node.properties[0];
|
|
@@ -3145,7 +3145,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3145
3145
|
name: prop.keyTparam.name
|
|
3146
3146
|
},
|
|
3147
3147
|
constraint: transformTypeAnnotationType(prop.sourceType),
|
|
3148
|
-
readonly: ((_prop$variance = prop.variance) == null ? void 0 : _prop$variance.kind) === 'plus',
|
|
3148
|
+
readonly: ((_prop$variance = prop.variance) == null ? void 0 : _prop$variance.kind) === 'plus' || ((_prop$variance2 = prop.variance) == null ? void 0 : _prop$variance2.kind) === 'readonly',
|
|
3149
3149
|
optional: prop.optional === 'Optional',
|
|
3150
3150
|
typeAnnotation: transformTypeAnnotationType(prop.propType),
|
|
3151
3151
|
nameType: null
|
|
@@ -3366,10 +3366,10 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3366
3366
|
},
|
|
3367
3367
|
|
|
3368
3368
|
ObjectTypeIndexer(node) {
|
|
3369
|
-
var _node$
|
|
3369
|
+
var _node$variance3, _node$variance4;
|
|
3370
3370
|
|
|
3371
3371
|
if (node.key.type === 'GenericTypeAnnotation') {
|
|
3372
|
-
var _node$variance;
|
|
3372
|
+
var _node$variance, _node$variance2;
|
|
3373
3373
|
|
|
3374
3374
|
const ident = node.key.id.type === 'Identifier' ? node.key.id : node.key.id.id;
|
|
3375
3375
|
return {
|
|
@@ -3391,7 +3391,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3391
3391
|
loc: DUMMY_LOC
|
|
3392
3392
|
}
|
|
3393
3393
|
},
|
|
3394
|
-
readonly: ((_node$variance = node.variance) == null ? void 0 : _node$variance.kind) === 'plus',
|
|
3394
|
+
readonly: ((_node$variance = node.variance) == null ? void 0 : _node$variance.kind) === 'plus' || ((_node$variance2 = node.variance) == null ? void 0 : _node$variance2.kind) === 'readonly',
|
|
3395
3395
|
static: node.static,
|
|
3396
3396
|
typeAnnotation: {
|
|
3397
3397
|
type: 'TSTypeAnnotation',
|
|
@@ -3414,7 +3414,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3414
3414
|
typeAnnotation: transformTypeAnnotationType(node.key)
|
|
3415
3415
|
}
|
|
3416
3416
|
}],
|
|
3417
|
-
readonly: ((_node$
|
|
3417
|
+
readonly: ((_node$variance3 = node.variance) == null ? void 0 : _node$variance3.kind) === 'plus' || ((_node$variance4 = node.variance) == null ? void 0 : _node$variance4.kind) === 'readonly',
|
|
3418
3418
|
static: node.static,
|
|
3419
3419
|
typeAnnotation: {
|
|
3420
3420
|
type: 'TSTypeAnnotation',
|
|
@@ -3425,7 +3425,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3425
3425
|
},
|
|
3426
3426
|
|
|
3427
3427
|
ObjectTypeProperty(node) {
|
|
3428
|
-
var _node$
|
|
3428
|
+
var _node$variance5, _node$variance6;
|
|
3429
3429
|
|
|
3430
3430
|
const [key, computed] = (() => {
|
|
3431
3431
|
if (node.key.type === 'Identifier' && node.key.name.startsWith('@@')) {
|
|
@@ -3509,7 +3509,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3509
3509
|
computed,
|
|
3510
3510
|
key,
|
|
3511
3511
|
optional: node.optional,
|
|
3512
|
-
readonly: ((_node$
|
|
3512
|
+
readonly: ((_node$variance5 = node.variance) == null ? void 0 : _node$variance5.kind) === 'plus' || ((_node$variance6 = node.variance) == null ? void 0 : _node$variance6.kind) === 'readonly',
|
|
3513
3513
|
static: node.static,
|
|
3514
3514
|
typeAnnotation: {
|
|
3515
3515
|
type: 'TSTypeAnnotation',
|
|
@@ -3631,7 +3631,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
|
|
|
3631
3631
|
},
|
|
3632
3632
|
|
|
3633
3633
|
TupleTypeAnnotation(node) {
|
|
3634
|
-
const allReadOnly = node.elementTypes.length > 0 && node.elementTypes.every(element => element.type === 'TupleTypeLabeledElement' && element.variance != null && element.variance.kind === 'plus');
|
|
3634
|
+
const allReadOnly = node.elementTypes.length > 0 && node.elementTypes.every(element => element.type === 'TupleTypeLabeledElement' && element.variance != null && (element.variance.kind === 'plus' || element.variance.kind === 'readonly'));
|
|
3635
3635
|
const elems = node.elementTypes.map(element => {
|
|
3636
3636
|
switch (element.type) {
|
|
3637
3637
|
case 'TupleTypeLabeledElement':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flow-api-translator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
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",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"@typescript-eslint/parser": "8.38.0",
|
|
14
14
|
"@typescript-eslint/visitor-keys": "8.38.0",
|
|
15
15
|
"flow-enums-runtime": "^0.0.6",
|
|
16
|
-
"hermes-eslint": "0.
|
|
17
|
-
"hermes-estree": "0.
|
|
18
|
-
"hermes-parser": "0.
|
|
19
|
-
"hermes-transform": "0.
|
|
16
|
+
"hermes-eslint": "0.35.0",
|
|
17
|
+
"hermes-estree": "0.35.0",
|
|
18
|
+
"hermes-parser": "0.35.0",
|
|
19
|
+
"hermes-transform": "0.35.0",
|
|
20
20
|
"typescript": "5.3.2"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|