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

Question: top-level interface and ES6 "export default AssignmentExpression" #2490

Closed
zhuravlikjb opened this issue Mar 25, 2015 · 2 comments
Closed
Labels
Question An issue which isn't directly actionable in code

Comments

@zhuravlikjb
Copy link

I see that this works in compiler built from recent sources:

export default A;
interface A {}

According to the ES6 specification, after "export default" we only have three options:

  1. class declaration
  2. hoistable declaration (i.e., function or generator declaration)
  3. AssignmentExpression

If we treat "A" from my example as an AssignmentExpression, then it should work exactly the same way as AssignmentExpression in any other place, e.g. "var x = A".

For "var x = A" we reasonably have 'Cannot find name A'.
But in my example above, 'A' is resolved.

It means, that after 'export default' we have something different from an ordinary AssignmentExpression.

Are there some special rules for what can appear after export default in the statement?
Does it have a special meaning in case of "export default Identifier"?
Thanks!

@mhegazy
Copy link
Contributor

mhegazy commented Mar 25, 2015

Note: there are some additional changes to how export default and export = work that is not in master now. see #2460 for more details.

In the current implementation export default Identifier indicates exporting all meanings of the Identifier (value, type and namespace), that is the same behavior in export = Identifier.

At compile time the compiler will elide exports that do not have a value, and in the given example, interface A, the export default statement, and any imports to the default binding in other modules will not be written to your .js output.

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Mar 25, 2015
@zhuravlikjb
Copy link
Author

Thanks a lot, now it's clear for me, and I see that #2460 is merged into master, so I'll see and try the new changes. You may close this question, thanks.

@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
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

2 participants