babel-plugin-parameter-decorator
Advanced tools
Comparing version 1.0.12 to 1.0.13
@@ -51,2 +51,15 @@ "use strict"; | ||
var getParamReplacement = function getParamReplacement(path) { | ||
switch (path.node.type) { | ||
case 'ObjectPattern': | ||
return types.ObjectPattern(path.node.properties); | ||
case 'TSParameterProperty': | ||
return types.Identifier(path.node.parameter.name); | ||
default: | ||
return types.Identifier(path.node.name); | ||
} | ||
}; | ||
return { | ||
@@ -174,3 +187,3 @@ visitor: { | ||
(path.get('params') || []).slice().forEach(function (param) { | ||
var name = param.node.type === 'TSParameterProperty' ? param.node.parameter.name : param.node.name; | ||
var replacement = getParamReplacement(param); | ||
var decorators = param.node.decorators || []; | ||
@@ -237,3 +250,3 @@ var transformable = decorators.length; | ||
if (transformable) { | ||
param.replaceWith(types.Identifier(name)); | ||
param.replaceWith(replacement); | ||
} | ||
@@ -240,0 +253,0 @@ }); |
{ | ||
"name": "babel-plugin-parameter-decorator", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "Function parameter decorator transform plugin for babel v7, just like typescript.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
14395
225