flow-remove-types 2.161.0 → 2.164.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 +21 -27
- package/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
flow-remove-types
|
|
2
|
-
=================
|
|
1
|
+
# flow-remove-types
|
|
3
2
|
|
|
4
3
|
[](https://www.npmjs.com/package/flow-remove-types)
|
|
5
|
-
[](https://travis-ci.org/flowtype/flow-remove-types)
|
|
6
4
|
|
|
7
5
|
Turn your JavaScript with [Flow](https://flowtype.org/) type annotations into
|
|
8
6
|
standard JavaScript in an instant with no configuration and minimal setup.
|
|
9
7
|
|
|
10
|
-
[Flow](https://
|
|
8
|
+
[Flow](https://flow.org/) provides static type checking to JavaScript which
|
|
11
9
|
can both help find and detect bugs long before code is deployed and can make
|
|
12
10
|
code easier to read and more self-documenting. The Flow tool itself only reads
|
|
13
11
|
and analyzes code. Running code with Flow type annotations requires first
|
|
@@ -20,23 +18,22 @@ every browser.
|
|
|
20
18
|
`flow-remove-types` is a faster, simpler, zero-configuration alternative with
|
|
21
19
|
minimal dependencies for super-fast `npm install` time.
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
## Get Started!
|
|
21
|
+
## Getting Started
|
|
25
22
|
|
|
26
23
|
Use the command line:
|
|
27
24
|
|
|
28
|
-
```
|
|
25
|
+
```bash
|
|
29
26
|
npm install --global flow-remove-types
|
|
30
27
|
```
|
|
31
28
|
|
|
32
|
-
```
|
|
29
|
+
```bash
|
|
33
30
|
flow-remove-types --help
|
|
34
31
|
flow-remove-types input.js > output.js
|
|
35
32
|
```
|
|
36
33
|
|
|
37
34
|
Or the JavaScript API:
|
|
38
35
|
|
|
39
|
-
```
|
|
36
|
+
```bash
|
|
40
37
|
npm install flow-remove-types
|
|
41
38
|
```
|
|
42
39
|
|
|
@@ -51,7 +48,7 @@ fs.writeFileSync('output.js', output.toString());
|
|
|
51
48
|
|
|
52
49
|
When using the `flow-remove-types` script, be sure [not to direct the output to itself](https://superuser.com/questions/597244/why-does-redirecting-the-output-of-a-file-to-itself-produce-a-blank-file)!
|
|
53
50
|
|
|
54
|
-
## Use in Build Systems
|
|
51
|
+
## Use in Build Systems
|
|
55
52
|
|
|
56
53
|
**Rollup:** [`rollup-plugin-flow`](https://github.com/leebyron/rollup-plugin-flow)
|
|
57
54
|
|
|
@@ -61,25 +58,24 @@ When using the `flow-remove-types` script, be sure [not to direct the output to
|
|
|
61
58
|
|
|
62
59
|
**Gulp:** [`gulp-flow-remove-types`](https://github.com/wain-pc/gulp-flow-remove-types)
|
|
63
60
|
|
|
64
|
-
|
|
65
61
|
## Use with existing development tools
|
|
66
62
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
* ESLint: [eslint-plugin-flowtype](https://github.com/gajus/eslint-plugin-flowtype)
|
|
64
|
+
* Mocha: `mocha -r flow-remove-types/register`
|
|
65
|
+
* Jest: Add to your config:
|
|
66
|
+
|
|
67
|
+
```js
|
|
71
68
|
transform: {
|
|
72
69
|
"^.+\\.js(?:\\.flow)?$": "flow-remove-types/jest"
|
|
73
70
|
}
|
|
74
71
|
```
|
|
75
72
|
|
|
76
|
-
|
|
77
73
|
## Use `flow-node`
|
|
78
74
|
|
|
79
75
|
Wherever you use `node` you can substitute `flow-node` and have a super fast
|
|
80
76
|
flow-types aware evaluator or REPL.
|
|
81
77
|
|
|
82
|
-
```
|
|
78
|
+
```bash
|
|
83
79
|
$ flow-node
|
|
84
80
|
> var x: number = 42
|
|
85
81
|
undefined
|
|
@@ -116,12 +112,11 @@ expressions. All files are included by default except those found in the
|
|
|
116
112
|
require('flow-remove-types/register')({ includes: /\/custom_path\// })
|
|
117
113
|
```
|
|
118
114
|
|
|
119
|
-
>
|
|
115
|
+
> **Don't use the require hook in packages distributed on NPM**
|
|
120
116
|
> As always, don't forget to use `flow-remove-types` to compile files before distributing
|
|
121
117
|
> your code on npm, as using the require hook affects the whole runtime and not
|
|
122
118
|
> just your module and may hurt the runtime performance of code that includes it.
|
|
123
119
|
|
|
124
|
-
|
|
125
120
|
## Dead-Simple Transforms
|
|
126
121
|
|
|
127
122
|
When `flow-remove-types` removes Flow types, it replaces them with whitespace.
|
|
@@ -182,7 +177,7 @@ export class MyClass extends SomeClass {
|
|
|
182
177
|
|
|
183
178
|
Rather not have the whitespace? Pass the `--pretty` flag to remove the whitespace.
|
|
184
179
|
|
|
185
|
-
```
|
|
180
|
+
```bash
|
|
186
181
|
flow-remove-types --pretty --sourcemaps source.js
|
|
187
182
|
```
|
|
188
183
|
|
|
@@ -199,18 +194,17 @@ var sourceMap = output.generateMap();
|
|
|
199
194
|
fs.writeFileSync('output.js.map', JSON.stringify(sourceMap));
|
|
200
195
|
```
|
|
201
196
|
|
|
202
|
-
|
|
203
197
|
## Performance
|
|
204
198
|
|
|
205
199
|
> *NOTE*: These timings are for `flow-remove-types` v1.
|
|
206
200
|
|
|
207
|
-
### Install
|
|
201
|
+
### Install
|
|
208
202
|
|
|
209
203
|
Installing via `npm` from an empty project:
|
|
210
204
|
|
|
211
205
|
**flow-remove-types:**
|
|
212
206
|
|
|
213
|
-
```
|
|
207
|
+
```bash
|
|
214
208
|
time npm install flow-remove-types
|
|
215
209
|
|
|
216
210
|
real 0m3.193s
|
|
@@ -220,7 +214,7 @@ sys 0m0.775s
|
|
|
220
214
|
|
|
221
215
|
**Babel:**
|
|
222
216
|
|
|
223
|
-
```
|
|
217
|
+
```bash
|
|
224
218
|
time npm install babel-cli babel-plugin-transform-flow-strip-types
|
|
225
219
|
|
|
226
220
|
real 0m23.200s
|
|
@@ -228,13 +222,13 @@ user 0m10.395s
|
|
|
228
222
|
sys 0m4.238s
|
|
229
223
|
```
|
|
230
224
|
|
|
231
|
-
### Transform
|
|
225
|
+
### Transform
|
|
232
226
|
|
|
233
227
|
Transforming a directory of 20 files of 100 lines each:
|
|
234
228
|
|
|
235
229
|
**flow-remove-types:**
|
|
236
230
|
|
|
237
|
-
```
|
|
231
|
+
```bash
|
|
238
232
|
time flow-remove-types src/ --out-dir dest/
|
|
239
233
|
|
|
240
234
|
real 0m0.431s
|
|
@@ -244,7 +238,7 @@ sys 0m0.068s
|
|
|
244
238
|
|
|
245
239
|
**Babel:**
|
|
246
240
|
|
|
247
|
-
```
|
|
241
|
+
```bash
|
|
248
242
|
time babel src/ --out-dir dest/
|
|
249
243
|
|
|
250
244
|
real 0m1.074s
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flow-remove-types",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.164.0",
|
|
4
4
|
"description": "Removes Flow type annotations from JavaScript files with speed and simplicity.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Flow Team",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"es6"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"flow-parser": "^0.
|
|
47
|
+
"flow-parser": "^0.164.0",
|
|
48
48
|
"pirates": "^3.0.2",
|
|
49
49
|
"vlq": "^0.2.1"
|
|
50
50
|
},
|