From 5cd1276a27277c495cf4ea81bc429f1746febaad Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Wed, 23 May 2018 13:40:22 -0700 Subject: [PATCH] Expose the Flow 'all' option on the preset too. (#8016) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit | Q                       | A | ------------------------ | --- | Fixed Issues? | | Patch: Bug Fix? | | Major: Breaking Change? | | Minor: New Feature? | | Tests Added + Pass? | Yes | Documentation PR | | Any Dependency Changes? | | License | MIT The `all` option landed in https://github.com/babel/babel/pull/7934/files#diff-3a8233bcd2766d2c7d87f23f944f7726R3 but it is only exposed from the plugin, not the preset, so this exposes it there too since the flow preset is what we want people to use. --- packages/babel-plugin-syntax-flow/src/index.js | 4 ++++ packages/babel-preset-flow/src/index.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/babel-plugin-syntax-flow/src/index.js b/packages/babel-plugin-syntax-flow/src/index.js index a7fcf7203a..7f80f4843a 100644 --- a/packages/babel-plugin-syntax-flow/src/index.js +++ b/packages/babel-plugin-syntax-flow/src/index.js @@ -7,6 +7,10 @@ export default declare((api, options) => { // the @flow pragma was provided. const { all } = options; + if (typeof all !== "boolean" && typeof all !== "undefined") { + throw new Error(".all must be a boolean, or undefined"); + } + return { manipulateOptions(opts, parserOpts) { // If the file has already enabled TS, assume that this is not a diff --git a/packages/babel-preset-flow/src/index.js b/packages/babel-preset-flow/src/index.js index 7dc163bdbf..6fbd56a196 100644 --- a/packages/babel-preset-flow/src/index.js +++ b/packages/babel-preset-flow/src/index.js @@ -1,10 +1,10 @@ import { declare } from "@babel/helper-plugin-utils"; import transformFlowStripTypes from "@babel/plugin-transform-flow-strip-types"; -export default declare(api => { +export default declare((api, { all }) => { api.assertVersion(7); return { - plugins: [transformFlowStripTypes], + plugins: [[transformFlowStripTypes, { all }]], }; });