@babel/plugin-transform-typeof-symbol

typeof-symbol - 图1info

This plugin is included in @babel/preset-env

Example

In

JavaScript

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

Out

JavaScript

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

Installation

  • npm
  • Yarn
  • pnpm
  1. npm install --save-dev @babel/plugin-transform-typeof-symbol
  1. yarn add --dev @babel/plugin-transform-typeof-symbol
  1. pnpm add --save-dev @babel/plugin-transform-typeof-symbol

Usage

babel.config.json

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

Via CLI

Shell

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

Via Node API

JavaScript

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