import PI from "./pi";
export function surface(radius) {
return PI * radius * radius / 2.0;
}
编译为:
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.surface = surface;
var _pi = _interopRequireDefault(require("./pi"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function surface(radius) {
return _pi.default * radius * radius / 2.0;
}
如果将noInterop选项设置为true。生成的新代码为:
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.surface = surface;
var _pi = require("./pi");
function surface(radius) {
return _pi.default * radius* radius/ 2.0;
}
为什么Object.defineProperty调用仍然存在?