flow-upgrade 2.4.0 → 2.5.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/README.md +7 -0
- package/dist/codemods/replaceTemporaryTypes.js +56 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -98,3 +98,10 @@ Run with `yarn run flow-codemod typeCastToAsExpression`.
|
|
|
98
98
|
Converts usages of the internal React types like `React$Node` to public facing ones like `React.Node`.
|
|
99
99
|
|
|
100
100
|
Run with `yarn run flow-codemod replaceReactDollarUtilityTypes`.
|
|
101
|
+
|
|
102
|
+
### Replace `$TEMPORARY$*` types
|
|
103
|
+
Converts:
|
|
104
|
+
- `$TEMPORARY$object<{props}>` to `$ReadOnly<{props}>`
|
|
105
|
+
- `$TEMPORARY$array<T>` to `$ReadOnlyArray<T>`
|
|
106
|
+
- `$TEMPORARY$number<42>` annotations to `number`
|
|
107
|
+
- `$TEMPORARY$string<"foo">` annotations to `string`
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _hermesTransform = require("hermes-transform");
|
|
9
|
+
|
|
10
|
+
var _Types = require("../Types");
|
|
11
|
+
|
|
12
|
+
var _default = (0, _Types.codemod)({
|
|
13
|
+
describe: ['Converts:', ' - `$TEMPORARY$object<{props}>` to `$ReadOnly<{props}>`', ' - `$TEMPORARY$array<T>` to `$ReadOnlyArray<T>`', ' - `$TEMPORARY$number<42>` annotations to `number`', ' - `$TEMPORARY$string<"foo">` annotations to `string`'].join('\n'),
|
|
14
|
+
transform: context => {
|
|
15
|
+
return {
|
|
16
|
+
GenericTypeAnnotation(node) {
|
|
17
|
+
const id = node.id;
|
|
18
|
+
|
|
19
|
+
if (id.type === 'Identifier' && id.name === '$TEMPORARY$object' && node.typeParameters != null) {
|
|
20
|
+
context.modifyNodeInPlace(node, {
|
|
21
|
+
id: _hermesTransform.t.Identifier({
|
|
22
|
+
name: '$ReadOnly'
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (id.type === 'Identifier' && id.name === '$TEMPORARY$array' && node.typeParameters != null) {
|
|
28
|
+
context.modifyNodeInPlace(node, {
|
|
29
|
+
id: _hermesTransform.t.Identifier({
|
|
30
|
+
name: '$ReadOnlyArray'
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (id.type === 'Identifier' && id.name === '$TEMPORARY$number') {
|
|
36
|
+
const new_node = _hermesTransform.t.NumberTypeAnnotation();
|
|
37
|
+
|
|
38
|
+
context.replaceNode(node, new_node, {
|
|
39
|
+
keepComments: true
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (id.type === 'Identifier' && id.name === '$TEMPORARY$string') {
|
|
44
|
+
const new_node = _hermesTransform.t.StringTypeAnnotation();
|
|
45
|
+
|
|
46
|
+
context.replaceNode(node, new_node, {
|
|
47
|
+
keepComments: true
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flow-upgrade",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "A utility for upgrading your codebase to the latest version of Flow.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=14"
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"homepage": "https://github.com/facebook/flow/tree/master/packages/flow-upgrade#readme",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/highlight": "^7.18.6",
|
|
33
|
-
"babel-plugin-syntax-hermes-parser": "0.
|
|
33
|
+
"babel-plugin-syntax-hermes-parser": "0.24.0",
|
|
34
34
|
"chalk": "^2.0.1",
|
|
35
35
|
"fs-extra": "10.1.0",
|
|
36
|
-
"hermes-estree": "0.
|
|
37
|
-
"hermes-parser": "0.
|
|
38
|
-
"hermes-transform": "0.
|
|
36
|
+
"hermes-estree": "0.24.0",
|
|
37
|
+
"hermes-parser": "0.24.0",
|
|
38
|
+
"hermes-transform": "0.24.0",
|
|
39
39
|
"klaw-sync": "^6.0.0",
|
|
40
40
|
"ora": "^5.4.1",
|
|
41
|
-
"prettier-plugin-hermes-parser": "0.
|
|
41
|
+
"prettier-plugin-hermes-parser": "0.24.0",
|
|
42
42
|
"prompt-confirm": "^1.2.0",
|
|
43
43
|
"semver": "^7.3.7",
|
|
44
44
|
"yargs": "^17.0.1"
|