@babel/plugin-transform-flow-strip-types
Advanced tools
Comparing version 7.8.3 to 7.9.0
@@ -16,6 +16,10 @@ "use strict"; | ||
var _default = (0, _helperPluginUtils.declare)(api => { | ||
var _default = (0, _helperPluginUtils.declare)((api, opts) => { | ||
api.assertVersion(7); | ||
const FLOW_DIRECTIVE = /(@flow(\s+(strict(-local)?|weak))?|@noflow)/; | ||
let skipStrip = false; | ||
const { | ||
requireDirective = false, | ||
allowDeclareFields = false | ||
} = opts; | ||
return { | ||
@@ -30,4 +34,3 @@ name: "transform-flow-strip-types", | ||
} | ||
}, | ||
opts | ||
} | ||
}) { | ||
@@ -50,3 +53,3 @@ skipStrip = false; | ||
if (!directiveFound && opts.requireDirective) { | ||
if (!directiveFound && requireDirective) { | ||
skipStrip = true; | ||
@@ -81,9 +84,2 @@ } | ||
ClassProperty(path) { | ||
if (skipStrip) return; | ||
path.node.variance = null; | ||
path.node.typeAnnotation = null; | ||
if (!path.node.value) path.remove(); | ||
}, | ||
ClassPrivateProperty(path) { | ||
@@ -99,4 +95,18 @@ if (skipStrip) return; | ||
if (child.isClassProperty()) { | ||
child.node.typeAnnotation = null; | ||
if (!child.node.value) child.remove(); | ||
const { | ||
node | ||
} = child; | ||
if (!allowDeclareFields && node.declare) { | ||
throw child.buildCodeFrameError(`The 'declare' modifier is only allowed when the ` + `'allowDeclareFields' option of ` + `@babel/plugin-transform-flow-strip-types or ` + `@babel/preset-flow is enabled.`); | ||
} | ||
if (node.declare) { | ||
child.remove(); | ||
} else if (!allowDeclareFields && !node.value && !node.decorators) { | ||
child.remove(); | ||
} else { | ||
node.variance = null; | ||
node.typeAnnotation = null; | ||
} | ||
} | ||
@@ -103,0 +113,0 @@ }); |
{ | ||
"name": "@babel/plugin-transform-flow-strip-types", | ||
"version": "7.8.3", | ||
"version": "7.9.0", | ||
"description": "Strip flow type annotations from your output code.", | ||
@@ -22,6 +22,6 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-flow-strip-types", | ||
"devDependencies": { | ||
"@babel/core": "^7.8.3", | ||
"@babel/core": "^7.9.0", | ||
"@babel/helper-plugin-test-runner": "^7.8.3" | ||
}, | ||
"gitHead": "a7620bd266ae1345975767bbc7abf09034437017" | ||
"gitHead": "8d5e422be27251cfaadf8dd2536b31b4a5024b02" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6500
142