babel-plugin-transform-metadata
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -7,4 +7,11 @@ "use strict"; | ||
return function createCreateGenericTypeMetadata(createObjectTypeMetadata) { | ||
return function createGenericTypeMetadata(annotation) { | ||
return function createGenericTypeMetadata(annotation, typeParameters) { | ||
var id = annotation.id; | ||
if (typeParameters) { | ||
for (var i = 0; i < typeParameters.length; i++) { | ||
if (typeParameters[i].name === id.name) { | ||
return t.stringLiteral(id.name); | ||
} | ||
} | ||
} | ||
if (reservedGenerics.has(id.name)) { | ||
@@ -11,0 +18,0 @@ return createGenericTypeMetadata(annotation.typeParameters.params[0]); |
@@ -9,3 +9,3 @@ 'use strict'; | ||
function typeForAnnotation(annotation) { | ||
function typeForAnnotation(annotation, typeParameters) { | ||
if (!annotation) { | ||
@@ -26,3 +26,3 @@ return null; | ||
case 'GenericTypeAnnotation': | ||
return createGenericTypeMetadata(annotation); | ||
return createGenericTypeMetadata(annotation, typeParameters); | ||
case 'ObjectTypeAnnotation': | ||
@@ -29,0 +29,0 @@ return createObjectTypeMetadata(annotation); |
@@ -6,3 +6,3 @@ "use strict"; | ||
function createTypeForAnnotations(typeForAnnotation) { | ||
return function typeForAnnotations(types) { | ||
return function typeForAnnotations(types, typeParameters) { | ||
var result = []; | ||
@@ -12,3 +12,3 @@ for (var i = 0, l = types.length; i < l; i++) { | ||
var typeAnnotation = type.typeAnnotation && type.typeAnnotation.typeAnnotation; | ||
var id = typeForAnnotation(typeAnnotation); | ||
var id = typeForAnnotation(typeAnnotation, typeParameters); | ||
if (id) { | ||
@@ -15,0 +15,0 @@ result.push(id); |
@@ -20,3 +20,3 @@ 'use strict'; | ||
} | ||
var typeArgs = typeForAnnotations(types); | ||
var typeArgs = typeForAnnotations(types, node.typeParameters ? node.typeParameters.params : null); | ||
if (typeArgs.length) { | ||
@@ -23,0 +23,0 @@ body.push(t.expressionStatement(t.callExpression(metaDataId, [t.stringLiteral(paramKey), t.arrayExpression(typeArgs), target]))); |
{ | ||
"name": "babel-plugin-transform-metadata", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Reflection metadata support for classes and functions with flowtype type aliases support", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
113422
107
974