babel-plugin-flow-type-getter
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -38,4 +38,7 @@ class Test1 { | ||
typeof obj_test.t1.prop8 == 'User'); // false | ||
typeof Test1.prop2 == 'User'); // true | ||
Array.isArray(Test1.prop5)); // false | ||
const test1_str = 't1'; | ||
console.log('unary test : ', typeof obj_test[test1_str].prop1); // number | ||
console.log('binary test : ', typeof obj_test.t1.prop2 == 'User'); // true | ||
console.log('array test : ', Array.isArray(Test1.prop5)); // false | ||
console.log('array test : ', Array.isArray(obj_test['t2'].prop2)) // true |
15
index.js
@@ -153,7 +153,14 @@ const babylon = require('babylon'); | ||
if(t.isMemberExpression(node)) { | ||
return `${objectStringGenerator(node.object)}.${node.property.name}`; | ||
if(node.computed) { | ||
if(t.isStringLiteral(node.property)) { | ||
return `${objectStringGenerator(node.object)}['${node.property.value}']`; | ||
} | ||
else { | ||
return `${objectStringGenerator(node.object)}[${node.property.name}]`; | ||
} | ||
} | ||
else { | ||
return `${objectStringGenerator(node.object)}.${node.property.name}`; | ||
} | ||
} | ||
else if(t.isStringLiteral(node, { computed : true })) { | ||
return `${objectStringGenerator(node.object)}.['${node.property.name}']`; | ||
} | ||
else if(t.isIdentifier(node)) { | ||
@@ -160,0 +167,0 @@ return node.name; |
{ | ||
"name": "babel-plugin-flow-type-getter", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Access flow types from uninstantiated classes.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -58,6 +58,8 @@ ## Access your Flow types from classes before you instantiate objects. | ||
typeof obj_test.t1.prop8 == 'User'); // false | ||
typeof Test1.prop2 == 'User'); // true | ||
Array.isArray(Test1.prop5)); // false | ||
const test1_str = 't1'; | ||
console.log('unary test : ', typeof obj_test[test1_str].prop1); // number | ||
console.log('binary test : ', typeof obj_test.t1.prop2 == 'User'); // true | ||
console.log('array test : ', Array.isArray(Test1.prop5)); // false | ||
console.log('array test : ', Array.isArray(obj_test['t2'].prop2)) // true | ||
```` | ||
@@ -64,0 +66,0 @@ --- |
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
56334
1796
73