Skip to content

In JS, multiple prototype assignments give duplicate identifier error #23172

@sandersn

Description

@sandersn
function A() {
    this.x = 1
}
function Am(n) { }
if (!!!true) {
    A.prototype.m = Am
}
else {
    A.prototype.m = function() { }
}

Expected behavior:
Multiple assignments should be allowed, but there should a type error on the second assignment because the types of m do not match.

Actual behavior:
Duplicate identifier error on both declarations of m.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: JavaScriptThe issue relates to JavaScript specificallyWon't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix it

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions