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

Allow export default interface #3914

Closed
LPGhatguy opened this issue Jul 17, 2015 · 6 comments
Closed

Allow export default interface #3914

LPGhatguy opened this issue Jul 17, 2015 · 6 comments
Labels
Duplicate An existing issue was already created In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@LPGhatguy
Copy link
Contributor

The following snippet is valid, as far as I know:

export interface User {
    wpUserID: string;
}

The following snippet is also valid, but does not compile, but probably should:

export default interface User {
    wpUserID: string;
}

I get errors thrown at me when using TypeScript 1.5-beta:

Error: /Models/User.ts(1,26): Error TS1005: ';' expected.
Error: /Models/User.ts(1,31): Error TS1005: ';' expected.
@DanielRosenwasser
Copy link
Member

You can get around this with

interface I {

}

export default I;

I admit this is a somewhat strange inconsistency, but this is a duplicate of #3194 and is by design in accordance with a decision made on #3095 (comment).

@LPGhatguy
Copy link
Contributor Author

Interesting. Any chance there could be a warning about the behavior?

@danquirk
Copy link
Member

Linking to #3792 because they're very similar. We should just allow this kind of thing. There's no good reason to require you to write it in 2 statements instead of one.

@danquirk danquirk reopened this Jul 17, 2015
@danquirk danquirk changed the title Interfaces fail to export as default under ES6 module syntax Allow export default interface Jul 17, 2015
@danquirk danquirk added Suggestion An idea for TypeScript In Discussion Not yet reached consensus labels Jul 17, 2015
@dsherret
Copy link
Contributor

👍

Currently I am doing the "workaround" with everything for consistency, would be nice to switch though.

@clark-stevenson
Copy link

👍 Any kind of error would be welcome, it took a StackOverflow question to understand.

@mhegazy mhegazy closed this as completed Feb 22, 2016
@mhegazy mhegazy added the Duplicate An existing issue was already created label Feb 22, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Feb 22, 2016

closing in favor of #3792

@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
Duplicate An existing issue was already created In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

6 participants