Вы не проверяли это первым.С Бабелем все в порядке._switch()
- это ничто иное, как внутренний неэкспонированный метод, который Бабель создает во время транспиляции (то, что вам на самом деле не важно)Ваш доступный метод по-прежнему называется .switch()
, как и все вещи должны быть.
class TestClass{
switch(){
return "foo"
}
getState(){
}
}
console.log(new TestClass().switch()) //foo
console.log(new TestClass()._switch()) //undefined
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var TestClass = function () {
function TestClass() {
_classCallCheck(this, TestClass);
}
_createClass(TestClass, [{
key: "switch",
value: function _switch() {
return "foo";
}
}, {
key: "getState",
value: function getState() {}
}]);
return TestClass;
}();
console.log(new TestClass().switch())