forked from babel/babel
/
exec.js
38 lines (35 loc) · 812 Bytes
/
exec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var code = `
(function() {
var bar = 'lol';
function foo(b){
b === bar
foo(b);
}
})();
`;
transform(code, {
plugins: [
function (b) {
var t = b.types;
return {
visitor: {
// Replace block statements with a new node without changing anything
BlockStatement: function(path) {
if (path.node.seen) {
return;
}
var node = t.blockStatement(path.node.body);
node.seen = true;
path.replaceWith(node);
},
// do type inference
BinaryExpression: function(path) {
var left = path.get("left");
var right = path.get("right");
left.baseTypeStrictlyMatches(right);
}
}
};
}
]
});