Skip to content

TypeScript should be able to support method overloading #11702

Closed
@MrMatthewLayton

Description

@MrMatthewLayton

Since TypeScript is statically typed, it should be able to infer method usage based on supplied parameters, however I can already see a potential limitation in the emitted code - as long as JS is considered "read-only" this probably wont matter (much)

Example

class Test {
    public getResult(value: string): boolean {
        ...
    }

    public getResult(x: number, y: number, z: number): string {
        ...
    }
}

Compiled

var Test = (function () {
    function Test() {
    }

    Test.prototype.getResult$s0 = function(value) {
        ...
    }

    Test.prototype.getResult$n0$n1$n2 = function(x, y, z) {
        ...
    }

    return Test;
})();

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions