@babel/plugin-transform-typeof-symbol
NOTE: This plugin is included in
@babel/preset-env
Example
In
JavaScript
typeof Symbol() === "symbol";
Out
JavaScript
var _typeof = function(obj) {
return obj && obj.constructor === Symbol ? "symbol" : typeof obj;
};
_typeof(Symbol()) === "symbol";
Installation
- npm
- Yarn
- pnpm
npm install --save-dev @babel/plugin-transform-typeof-symbol
yarn add --dev @babel/plugin-transform-typeof-symbol
pnpm add --save-dev @babel/plugin-transform-typeof-symbol
Usage
With a configuration file (Recommended)
babel.config.json
{
"plugins": ["@babel/plugin-transform-typeof-symbol"]
}
Via CLI
Shell
babel --plugins @babel/plugin-transform-typeof-symbol script.js
Via Node API
JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-transform-typeof-symbol"],
});