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

export default class emits non-default export #2537

Closed
Arnavion opened this issue Mar 28, 2015 · 6 comments · Fixed by #2547
Closed

export default class emits non-default export #2537

Arnavion opened this issue Mar 28, 2015 · 6 comments · Fixed by #2547
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@Arnavion
Copy link
Contributor

This compiles and the output is correct.

class One {
    foo() {
        return this;
    }
}

export default One;
var One = (function () {
    function One() {
    }
    One.prototype.foo = function () {
        return this;
    };
    return One;
})();
exports.default = One;

Combining the class declaration and the export compiles, but the output is incorrect:

export default class One {
    foo() {
        return this;
    }
}
var One = (function () {
    function One() {
    }
    One.prototype.foo = function () {
        return this;
    };
    return One;
})();
exports.One = One;

The default is ignored.

@mhegazy mhegazy added the Bug A bug in TypeScript label Mar 29, 2015
@mhegazy mhegazy self-assigned this Mar 29, 2015
@mhegazy mhegazy added this to the TypeScript 1.5 milestone Mar 29, 2015
@ahejlsberg ahejlsberg assigned ahejlsberg and unassigned mhegazy Mar 30, 2015
@jeremyalan
Copy link

This appears to be broken again in 1.7... it appears to be working fine in 1.6.

Should this be reported as a new issue?

@vladima
Copy link
Contributor

vladima commented Dec 18, 2015

Can you please share a repro code since I cannot reproduce this issue locally?
This is what I got using the latest bits from master:

"use strict";
var One = (function () {
    function One() {
    }
    One.prototype.foo = function () {
        return this;
    };
    return One;
}());
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = One;

Looks like an expected output to me.

@jeremyalan
Copy link

I will try to post one when I get back to my computer... In the meantime, make sure you set --target es6 --module commonjs

@Arnavion
Copy link
Contributor Author

Yes, it's fine in master but 1.7.5 gives

class One {
    foo() {
        return this;
    }
}
exports.One = One;

@Arnavion
Copy link
Contributor Author

Perhaps inadvertently fixed by 83e61cf that changed emitClassLikeDeclarationForES6AndHigher to call emitExportMemberAssignment

Actually this is #5594 fixed by #5648

@jeremyalan
Copy link

Got it, thanks for the info!

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jan 5, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 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

Successfully merging a pull request may close this issue.

5 participants