Closed
Description
TypeScript Version: 3.9.2
Search Terms:
TS2323: Cannot redeclare exported variable, CommonJS, exports
Code
export const export1 = '';
export const export2 = '';
Expected behavior:
in TypeScript 3.8.x, with --module CommonJS
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.export1 = '';
exports.export2 = '';
Actual behavior:
in TypeScript 3.9.2, with --module CommonJS
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.export2 = exports.export1 = void 0;
exports.export1 = '';
exports.export2 = '';
Playground Link:
https://www.typescriptlang.org/play/?module=1&ts=3.9.2#code/KYDwDg9gTgLgBAYwgOwM71JWBGOBeOAckIG4AoTaeJNDcKgJnyNLKA
This is a regression because the code emitted leads to compiler errors when imported by javascript when --checkJs is true
error TS2323: Cannot redeclare exported variable 'export1'
error TS2323: Cannot redeclare exported variable 'export2'
I've worked around this by setting --declaration to true and excluding the javascript, but there doesn't seem to be a reason why this change was made.