Skip to content

Commonjs exports should allow duplicates in some cases #40555

Closed
@sandersn

Description

@sandersn

Follow-up to #40513, which surfaced an example of export duplicates that should be allowed:

exports.x = undefined
function x() { }
exports.x = x

This pattern is used in the async package's index.js.

Expected behavior:
No error; TS' emit uses this pattern too.

Actual behavior:
Error: "Cannot redeclare exported variable 'x'."

Currently commonjs exports use excludeFlags of SymbolFlags.None instead of SymbolFlags.Alias as normal aliases do. However, most duplicate alias detection happens in the checker already. All exports should switch to None instead of Alias, and then the above undefined exception can be added in one place in the checker.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions