aswi2020vldc-gitlab/templetes/node_modules/babel-preset-flow/README.md @ 143404cb
1 |
# babel-preset-flow
|
---|---|
2 |
|
3 |
> Babel preset for all Flow plugins.
|
4 |
|
5 |
This preset includes the following plugins: |
6 |
|
7 |
- [transform-flow-strip-types](https://babeljs.io/docs/plugins/transform-flow-strip-types/) |
8 |
|
9 |
## Example
|
10 |
|
11 |
**In**
|
12 |
|
13 |
```javascript |
14 |
function foo(one: any, two: number, three?): string {} |
15 |
```
|
16 |
|
17 |
**Out**
|
18 |
|
19 |
```javascript |
20 |
function foo(one, two, three) {} |
21 |
```
|
22 |
|
23 |
## Installation
|
24 |
|
25 |
```sh |
26 |
npm install --save-dev babel-preset-flow |
27 |
```
|
28 |
|
29 |
## Usage
|
30 |
|
31 |
### Via `.babelrc` (Recommended)
|
32 |
|
33 |
**.babelrc**
|
34 |
|
35 |
```json |
36 |
{
|
37 |
"presets": ["flow"] |
38 |
}
|
39 |
```
|
40 |
|
41 |
### Via CLI
|
42 |
|
43 |
```sh |
44 |
babel --presets flow script.js
|
45 |
```
|
46 |
|
47 |
### Via Node API
|
48 |
|
49 |
```javascript |
50 |
require("babel-core").transform("code", { |
51 |
presets: ["flow"] |
52 |
});
|
53 |
```
|