@babel/plugin-transform-typeof-symbol

NOTE: This plugin is included in @babel/preset-env

Example

In

  1. typeof Symbol() === "symbol";

Out

  1. var _typeof = function(obj) {
  2. return obj && obj.constructor === Symbol ? "symbol" : typeof obj;
  3. };
  4. _typeof(Symbol()) === "symbol";

Installation

  1. npm install --save-dev @babel/plugin-transform-typeof-symbol

Usage

  1. {
  2. "plugins": ["@babel/plugin-transform-typeof-symbol"]
  3. }

Via CLI

  1. babel --plugins @babel/plugin-transform-typeof-symbol script.js

Via Node API

  1. require("@babel/core").transformSync("code", {
  2. plugins: ["@babel/plugin-transform-typeof-symbol"],
  3. });