Skip to content

define get set bug. #11384

@Gaubee

Description

@Gaubee

TypeScript Version: 2.0.3

Code

// A *self-contained* demonstration of the problem follows...
var config = {
    ["__type"]: "QAQ",
    get type() { 
        return this.__type
    },
    set type(new_type) { 
        this.__type = new_type
    }
}

Expected behavior:

var config = (_a = {},
    _a["__type"] = "QAQ",
    Object.defineProperty(_a, "type", {
        get: function () {
            return this.__type;
        },
        set: function (new_type) {
            this.__type = new_type;
        },
        enumerable: true,
        configurable: true
    }),
    _a
);
var _a;

Actual behavior:
Uncaught SyntaxError: Unexpected token ,

var config = (_a = {},
    _a["__type"] = "QAQ",
    Object.defineProperty(_a, "type", {
        get: function () {
            return this.__type;
        },
        set: function (new_type) {
            this.__type = new_type;
        },
        enumerable: true,
        configurable: true
    }),
    , // Here, One more comma, then run error
    _a
);
var _a;

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