letConst option not working properly on its own
Hello,
In my use case I'm using buble
to transpile just let
and const
variables disabling every transforms
options except for letConst
. I believe this should be enough but it's not working as expected.
This is a sample where it's possible to reproduce the bug:
const a = 1;
if (a > 2) {
let node = 10;
node = 3;
node = 1;
} else if (a > 5) {
let node = 10;
node = 3;
node = 1;
}
And this is the output:
var a = 1;
if (a > 2) {
var node = 10;
node = 3;
node = 1;
} else if (a > 5) {
var node$1 = 10;
node = 3;
node = 1;
}
As you can see, the second declared node
is renamed but all the following assignments are not.
There are the buble
parameters:
const transpiled = buble.transform(code, {
transforms: {
letConst: true,
arrow: false,
modules: false,
forOf: false,
classes: false,
collections: false,
computedProperty: false,
conciseMethodProperty: false,
constLoop: false,
dangerousForOf: false,
dangerousTaggedTemplateString: false,
defaultParameter: false,
destructuring: false,
generator: false,
numericLiteral: false,
parameterDestructuring: false,
reservedProperties: false,
spreadRest: false,
stickyRegExp: false,
templateString: false,
unicodeRegExp: false
},
file: 'source.js',
output: 'source.js'
});
I also noticed that setting arrow
to true
solves the problem outputing the expected result:
var a = 1;
if (a > 2) {
var node = 10;
node = 3;
node = 1;
} else if (a > 5) {
var node$1 = 10;
node$1 = 3;
node$1 = 1;
}