This transformer wraps all `typeof` expressions with a method that replicates native behaviour. (ie. returning "symbol" for symbols)
GitHub · npm · Edit this page
In
typeof Symbol() === "symbol";
Out
var _typeof = function (obj) {
return obj && obj.constructor === Symbol ? "symbol" : typeof obj;
};
_typeof(Symbol()) === "symbol";
npm install --save-dev babel-plugin-transform-es2015-typeof-symbol
.babelrc
(Recommended).babelrc
{
"plugins": ["transform-es2015-typeof-symbol"]
}
babel --plugins transform-es2015-typeof-symbol script.js
require("babel-core").transform("code", {
plugins: ["transform-es2015-typeof-symbol"]
});