Skip to content

Incorrect emit for module M with import M inside it #1503

@JsonFreeman

Description

@JsonFreeman

Two different modules with the same last name. One imports the other with an alias of that same name. The variable M in the emitted code corresponding to A.M needs to be _M.

module Z.M {
    export function bar() {
        console.log(1);
    }
}
module A.M {
    import M = Z.M;
    export function bar() {
        console.log(2);
    }
    M.bar(); // Calls the wrong function at runtime, works if you change the above import to a var
}

This is a severe breaking change because it leads to subtle behavioral bugs at runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issueHigh Priority

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions