Microsoft/TypeScript
在 GitHub 查看.js error when module type is CommonJS and a variable name is exports
Open
#54,738 创建于 2023年6月22日
BugDomain: JS EmitHelp Wanted
仓库指标
- Star
- (48,455 star)
- PR 合并指标
- (平均合并 6天 17小时) (30 天内合并 9 个 PR)
描述
Bug Report
🔎 CommonJS exports
🕗 5.1.3
⏯ Playground Link
Playground link with relevant code
💻 Code
export let a = 1;
function b(exports: any) {
if (a == 1)
return exports.a;
else
return exports.b;
}
🙁 Actual behavior
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.a = void 0;
exports.a = 1;
function b(exports) {
if (exports.a == 1)
return exports.a;
else
return exports.b;
}
🙂 Expected behavior
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.a = void 0;
exports.a = 1;
function b(exports_1) {
if (exports.a == 1)
return exports_1.a;
else
return exports_1.b;
}