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 enums causes error #3320

Closed
seanchas116 opened this issue May 31, 2015 · 4 comments
Closed

export default enums causes error #3320

seanchas116 opened this issue May 31, 2015 · 4 comments
Labels
By Design Deprecated - use "Working as Intended" or "Design Limitation" instead

Comments

@seanchas116
Copy link
Contributor

export default
enum Foo {
  Bar, Baz
}

causes

test.ts(2,1): error TS1109: Expression expected.

error. (file is test.ts)

export
enum Foo {
  Bar, Baz
}

compiles successfully.

@DanielRosenwasser DanielRosenwasser added the By Design Deprecated - use "Working as Intended" or "Design Limitation" instead label May 31, 2015
@DanielRosenwasser
Copy link
Member

This is by design - ES6 just supports export default class ... and export default function ..., and so we support those, but we didn't add enums. If you find yourself sorely missing this, you can suggest that we allow enums to be declared as default exports as part of a separate issue, but as a trivial workaround, you can instead just write the following:

enum Foo {
  Bar, Baz
}

export default Foo;

@SetTrend
Copy link

SetTrend commented Jan 5, 2016

cc @RyanCavanaugh

I'd prefer to have this default export a first class citizen of the language, too. Same fo const enums.

If the workaround is trivial then I belive it should be integrated with the language, so one isn't required to remember this workaround every time it occurs.

@crbranch
Copy link

crbranch commented Feb 7, 2016

I would also vote for making export default enum a first-class citizen. While it's true that the workaround provided by @DanielRosenwasser is trivial, it certainly was not obvious to me beforehand. If the intention/goal is to steer people away from using export = and instead prefer using export default, then it would helpful to apply export default consistently for classes, interfaces, and enums.

@clavecoder
Copy link

I'm OK with leaving it as is if the reasoning is that interfaces, et al, are not vaid EcmaScript and #3917 is implemented.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
By Design Deprecated - use "Working as Intended" or "Design Limitation" instead
Projects
None yet
Development

No branches or pull requests

5 participants