Skip to content

Commit

Permalink
Additional cleanup for const transform
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoferbaxter committed Jan 8, 2020
1 parent 712d7b6 commit 6d706bb
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/transformers/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { Transform, TransformInterface } from '../types';
import { Transform, TransformInterface, Range } from '../types';
import { parse, walk } from '../acorn';
import { VariableDeclaration } from 'estree';
import { TransformSourceDescription } from 'rollup';
Expand All @@ -35,12 +35,9 @@ export default class ConstTransform extends Transform implements TransformInterf

walk.simple(program, {
VariableDeclaration(node: VariableDeclaration) {
if (node.kind === 'const' && node.range) {
source.overwrite(
node.range[0],
node.range[1],
code.substring(node.range[0], node.range[1]).replace('const ', 'let '),
);
const [start, end]: Range = node.range as Range;
if (node.kind === 'const') {
source.overwrite(start, end, code.substring(start, end).replace('const', 'let'));
}
},
});
Expand Down

0 comments on commit 6d706bb

Please sign in to comment.