Microsoft/TypeScript

.js error when module type is CommonJS and a variable name is exports

Open

#54.738 geöffnet am 22. Juni 2023

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
BugDomain: JS EmitHelp Wanted

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

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;
}

Contributor Guide