npm.io
0.12.2 • Published 5 years ago

@chialab/swc-types

Licence
MIT
Version
0.12.2
Deps
1
Size
21 kB
Vulns
0
Weekly
0
Stars
183
DeprecatedThis package is deprecated

SWC Types • A babel/types-like set of helpers for swc.

NPM

The development of this plugin has been suspended for maintenance reasons after an initial trial period. Developments will follow when the swc project will be more stable.


Install

$ npm i @chialab/swc-types -D
$ yarn add @chialab/swc-types -D

Usage

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;
    }
}

License

SWC Types is released under the MIT license.

Keywords