This project is read-only.

Compile Error - Language Specification(6.3 Function Overloads)

Topics: Language Specification
Nov 10, 2012 at 8:30 AM
Edited Nov 10, 2012 at 8:35 AM

function attr(name: string): string;
function attr(name: string, value: string): number;
function attr(map: any): number;
function attr(nameOrMap: any, value: string): any {
    if (nameOrMap && typeof nameOrMap == "object") {
        // handle map case
    } else {
        // handle string case

I tyied to compile this code, but compile error.

I think "function attr(nameOrMap: any, value: string): any" should be changed "function attr(nameOrMap: any, value?: string): any".