diff --git a/CHANGELOG.md b/CHANGELOG.md index 130ef2e9b6..53d2f32328 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ _Note: Gaps between patch versions are faulty/broken releases._ +## 3.6.4 + + * **New Feature** + * Add support for flow type casts and module types. + ## 3.6.3 * **Internal** diff --git a/lib/6to5/generation/generators/flow.js b/lib/6to5/generation/generators/flow.js index cc3d481d1a..fda54644d1 100644 --- a/lib/6to5/generation/generators/flow.js +++ b/lib/6to5/generation/generators/flow.js @@ -30,6 +30,7 @@ exports.ObjectTypeIndexer = exports.ObjectTypeProperty = exports.QualifiedTypeIdentifier = exports.UnionTypeAnnotation = +exports.TypeCastExpression = exports.VoidTypeAnnotation = function () { // todo: implement these once we have a `--keep-types` option }; diff --git a/lib/6to5/transformation/transformers/index.js b/lib/6to5/transformation/transformers/index.js index 155ca3042c..698fb05da5 100644 --- a/lib/6to5/transformation/transformers/index.js +++ b/lib/6to5/transformation/transformers/index.js @@ -12,6 +12,7 @@ module.exports = { "playground.objectGetterMemoization": require("./playground/object-getter-memoization"), reactCompat: require("./other/react-compat"), + flow: require("./other/flow"), react: require("./other/react"), _modules: require("./internal/modules"), diff --git a/lib/6to5/transformation/transformers/other/flow.js b/lib/6to5/transformation/transformers/other/flow.js new file mode 100644 index 0000000000..03da75ef41 --- /dev/null +++ b/lib/6to5/transformation/transformers/other/flow.js @@ -0,0 +1,13 @@ +var t = require("../../../types"); + +exports.TypeCastExpression = function (node) { + return node.expression; +}; + +exports.ImportDeclaration = function (node) { + if (node.type) this.remove(); +}; + +exports.ExportDeclaration = function (node) { + if (t.isTypeAlias(node.declaration)) this.remove(); +}; diff --git a/lib/6to5/types/visitor-keys.json b/lib/6to5/types/visitor-keys.json index 669a88f680..dd3a0f41ea 100644 --- a/lib/6to5/types/visitor-keys.json +++ b/lib/6to5/types/visitor-keys.json @@ -92,6 +92,7 @@ "TypeofTypeAnnotation": [], "TypeAlias": [], "TypeAnnotation": [], + "TypeCastExpression": ["expression"], "TypeParameterDeclaration": [], "TypeParameterInstantiation": [], "ObjectTypeAnnotation": [],