SWC Types • A babel/types-like set of helpers for swc.
👷♂️👷 This project is a work in progress.
$ npm i @chialab/swc-types -D
$ yarn add @chialab/swc-types -D
import { t, Visitor } from '@chialab/swc-types';
export class ConsoleVisitor extends Visitor {
visitCallExpression(e: CallExpression): Expression {
if (!t.isMemberExpression(e.callee)) {
return e;
}
if (t.isIdentifier(e.callee.object) && e.callee.object.value === 'console') {
if (t.isIdentifier(e.callee.property)) {
return t.unaryExpression('void', t.numericLiteral(0));
}
}
return e;
}
}
SWC Types is released under the MIT license.