Skip to content
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

Abstract getter/setter #11898

Closed
dungdm93 opened this issue Oct 27, 2016 · 3 comments
Closed

Abstract getter/setter #11898

dungdm93 opened this issue Oct 27, 2016 · 3 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@dungdm93
Copy link

TypeScript Version: 2.0.3

Code

abstract class Abstract {
    abstract set foo(value: string);
    abstract get bar(): string;
    abstract biz: number;
}

class Concrete extends Abstract {
    biz: number;
    constructor(public foo: string, public bar: string) {
        super();
        this.biz = 20;
    }

    toString(): string {
        return `${this.foo} ${this.bar}`;
    }
}

let i: Abstract = new Concrete("Hello", "World");
console.log(i.toString()); // undefined undefined

Expected behavior:
print Hello world

Actual behavior:
print undefined undefined

So look at Abstract class in JavaScript. foo & bar implementations are generated even they declared as abstract.

var Abstract = (function () {
    function Abstract() {
    }
    Object.defineProperty(Abstract.prototype, "foo", {
        set: function (value) { },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Abstract.prototype, "bar", {
        get: function () { },
        enumerable: true,
        configurable: true
    });
    return Abstract;
}());
@dungdm93
Copy link
Author

#11596

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Oct 27, 2016
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 2.1 milestone Oct 27, 2016
@mhegazy mhegazy modified the milestones: TypeScript 2.1, TypeScript 2.1.2 Oct 27, 2016
@rbuckton
Copy link
Member

@dungdm93: This has already been addressed in master with our new emitter. You should be able to test these changes using our nightly builds. If you are using NodeJS, you can install the latest nightly build via npm install typescript@next.

@RyanCavanaugh RyanCavanaugh added the Fixed A PR has been merged for this issue label Oct 31, 2016
@dungdm93
Copy link
Author

dungdm93 commented Nov 1, 2016

@rbuckton thanks. :)

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants