Skip to content

Extended members disappear when extending native classes #12136

Closed
@landonpoch

Description

@landonpoch

TypeScript Version: 2.1.1 / nightly (2.1.0-dev.20161109)

Code

class Exception extends Error {
    constructor(msg: string) {
        super(msg);
    }

    public printMsg() {
        console.log(this.message);
    }
}

let e = new Exception("testing!");
e.printMsg(); // printMsg is now undefined

Expected behavior:
Members defined on the extending class should be available for use. This worked fine a few days ago for me in 2.0.x. Upgrading to 2.1.x I have seen this issue.

Actual behavior:
Members are undefined.

It's possible I may be doing something wrong here but it seems to me that this should work. I wonder if this has anything to do with how inheritance is generated to support Custom Elements (https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#use-returned-values-from-super-calls-as-this)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions