Skip to content

Latest commit

 

History

History
 
 

swc-types

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

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

NPM


👷‍♂️👷 This project is a work in progress.


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.