Skip to content

Inconsistent multiple export behavior for functions vs vars #10122

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
evmar opened this issue Aug 3, 2016 · 1 comment · Fixed by #55387
Closed

Inconsistent multiple export behavior for functions vs vars #10122

evmar opened this issue Aug 3, 2016 · 1 comment · Fixed by #55387
Labels
Bug A bug in TypeScript

Comments

@evmar
Copy link
Contributor

evmar commented Aug 3, 2016

[email protected]

export type A = string;
function A() {}
export {A}

type B = string;
var B: void;
export {B};

The compiler accepts this module, and if you import it, you'll find that A is only exported as a type, not a value, but that B is both a type and value.

Note that two lines (1 and 3) both attempt to export A. If you make the B block try to do the same thing (add export before the first declaration of B) the compiler rejects the module with: "Individual declarations in merged declaration 'B' must be all exported or all local".

I suspect the right resolution of this is that it should reject the double export of A as well in this module.

@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Aug 4, 2016
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 2.1 milestone Aug 4, 2016
@DanielRosenwasser
Copy link
Member

Yup, and I agree that we should disallow the double export.

evmar added a commit to angular/tsickle that referenced this issue Aug 5, 2016
Summary:
A TypeScript interface becomes a Closure function.
The previous code attempted to export that function when the
interface was exported, but due to
  microsoft/TypeScript#10122
it actually wasn't exporting.

You can see this in the new test goldens, where export.js now
includes "Bar" as an export.  (Bar is a TypeScript interface but
at the Closure level it is a value and must be in the module
exports.)

This also lets us remove a crazy forward declare hack that actually
wasn't necessary -- it was just working around that the export
wasn't working.

This matches the exporting behavior in d090fe4.

Reviewers: rkirov

Reviewed By: rkirov

Subscribers: typescript-eng

Differential Revision: https://reviews.angular.io/D213
@mhegazy mhegazy modified the milestones: Future, TypeScript 2.1 Sep 29, 2016
@mhegazy mhegazy assigned ghost Sep 29, 2016
@RyanCavanaugh RyanCavanaugh unassigned ghost Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants