Skip to content

Extended members disappear when extending native classes #12136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
landonpoch opened this issue Nov 10, 2016 · 2 comments
Closed

Extended members disappear when extending native classes #12136

landonpoch opened this issue Nov 10, 2016 · 2 comments

Comments

@landonpoch
Copy link

landonpoch commented Nov 10, 2016

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)

@aluanhaddad
Copy link
Contributor

See #12123

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label May 24, 2017
@RyanCavanaugh RyanCavanaugh removed the Needs Investigation This issue needs a team member to investigate its status. label Sep 18, 2019
@RyanCavanaugh
Copy link
Member

This is in the FAQ now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants